SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to select all from two different tables in one query?

    I am trying to select all from two of my tables and have been experimenting with JOINS, but having no luck, I also cannot seem to find an example where a simple SELECT * from multiple tables has been accomplished. Basically I need data from two tables, one called product_catalogue, and one called products, I want everything from these two, this is how I have been doing this in SQL server 2008 management studio:

    Code:
    select * from product_catalogue where catalogueid =(select catalogueid from products where productid = 1)  (select * from products where productid = 1)
    I know the above is basically two queries, I want to merge them as one so I can use them in my PHP, can anyone provide any suggestions as to how I can accomplish this?

    Many thanks for all your help.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    697
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    select <columnsOfInterest> 
      from product_catalogue 
      join products
        on product_catalogue.catalogueid = products.catalogueid 
     where products.productid = 1

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much SwampBoogie that worked perfectly! I wish I could reward you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •