How to search for a data form 5 MySQL table at a time?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kadir Razu
    New Member
    • Feb 2011
    • 13

    How to search for a data form 5 MySQL table at a time?

    I have a MySQL database nammed 'pstu alumni' and five table inside this DB nammed 'agriculture',' bba','cse','dvm ' and 'fisheries' each table with same field common 'Name' and 'Session'.
    Then how can I search for a name from these five table at a time and how to show results?

    Please help...

    Thanks
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Kadir,

    Try using a Union query, if you want everything to appear in two columns.

    Cheers!

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      This is usually done with a JOIN statement.
      JOIN USING(Name) or Session

      Comment

      • Kadir Razu
        New Member
        • Feb 2011
        • 13

        #4
        Thanks a lot for your response...

        Can u plz suggest me the queary in details to do the task specified.

        Thanks...

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          You haven't specified a task, you have asked how to query five tables.
          I think you need to make an attempt yourself then come back with any specific problems

          Comment

          • Kadir Razu
            New Member
            • Feb 2011
            • 13

            #6
            I want to search these tabe at a time for a name e.g 'Shoham'.
            If match found (e.g. Name='Shoham'), then details information of that person (Shoham) need to print in another page from raw of the table where match found.

            Note : I am using php

            Comment

            • Oralloy
              Recognized Expert Contributor
              • Jun 2010
              • 988

              #7
              Code:
              SELECT Name, Session FROM Table1
              UNION
              SELECT Name, Session FROM Table2
              Try looking here for documentation on the SELECT UNION.

              Comment

              • Kadir Razu
                New Member
                • Feb 2011
                • 13

                #8
                Thanks "Oralloy" For Your Valuable Response...

                That technique works !

                Thanks a lot...

                Comment

                Working...