Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get data check from multiple tables?

    Hi,
    I have multiple table
    Table -1
    order_no name
    1 raj

    table -2
    order_no name
    1 raj

    table 3
    order_no name
    1 raj

    table 4
    order_no name
    1 raj

    table 5
    order_no name
    1 raj

    I want a query to check if the id (one) is present in all tables or not,
    i create this.


    select order_no from prepress, press, postpress, qc, binding, dispatch where order_no=prepress.order_no AND order_no=press.order_no AND order_no=postpress.order_no AND order_no=qc.order_no AND order_no=binding.order_no AND order_no=dispatch.order_no
    but the ambiguous error for order_no.

    how to achieve this can anyone suggest me?
    thanks

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,944
    Thanks
    2
    Thanked 170 Times in 165 Posts
    You need to include the order_no field from each table in the select clause portion of the statement. The from clause uses join statements/clauses to link the tables. The where clause specifies the value of the order_no that you want to check.

    For readability and maintainability it would be best to split the statement up into multiple lines.

    mysql select syntax
    mysql join syntax

  • #3
    New Coder
    Join Date
    May 2014
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use like this WHERE table1.order_no
    Specifying table name is necessary with column name to fetch data from various tables.


  •  

    Tags for this Thread

    Posting Permissions

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