#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Compare the results with the table and show the resuts whcih are not updated


    hi

    i have table "reports" in database with some colums

    one coloumn as DEVICE_ID

    i want to fetch the device_id which are update in last 24 hours and compare with other table "vehicles" and display

    results whcih are not updated


    i am able to get the results for the last 24 hours
    but unable to compare the query result with the other table
    and show in php

    query is like this

    SELECT DISTINCT device_id
    FROM reports
    WHERE TIMEDIFF( NOW( ) , device_date ) < '24:00:00'
    LIMIT 0 , 30

    thanks
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,027
    Rep Power
    4210
    Originally Posted by imranunicorn
    i want to fetch the device_id which are update in last 24 hours and compare with other table "vehicles"
    you can't compare a column with a table

    please be more explicit in what you're trying to do
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by r937
    you can't compare a column with a table

    please be more explicit in what you're trying to do

    in one table i am querying and getting results i want to compare the results with the other table coloumn

    1 table reports
    2 table vehicles

    i am quering reports table to get device id last update in 24 hours ,i am getting the results

    now i want to compare the results from table one with 2 table that is vehcile and show the results which are not same

    thank you
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,027
    Rep Power
    4210
    Originally Posted by imranunicorn
    now i want to compare the results from table one with 2 table that is vehcile and show the results which are not same
    you can't compare a column with a table

    please be more explicit in what you're trying to do
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    59
    Rep Power
    3
    Originally Posted by imranunicorn
    in one table i am querying and getting results i want to compare the results with the other table coloumn

    1 table reports
    2 table vehicles

    i am quering reports table to get device id last update in 24 hours ,i am getting the results

    now i want to compare the results from table one with 2 table that is vehcile and show the results which are not same

    thank you
    Hi,

    could use please run a SHOW CREATE TABLE for the 2 tables and post the results here?
    once that's done, could you please let us know which column(s) specifically in the vehicles table you want to compare to the results of that query?

IMN logo majestic logo threadwatch logo seochat tools logo