mysql - how to fetch data from two tables -
i have 2 tables
table a
imei_no | user_name | date_of_allocation | date_of_deallocation 123 | | 1-4-2013 | 10-4-2013 456 | | 10-4-2013 | 25-4-2013 789 | | 25-4-2013 | 30-4-2013 123 | b | 25-4-2013 | 27-4-2013
table b
imei | lat | long | gpsdate 123 | 23 | 43 | 2-4-2013 123 | 23 | 43 | 2-4-2013 456 | 23 | 43 | 3-4-2013 123 | 23 | 43 | 3-4-2013 789 | 23 | 43 | 24-4-2013 123 | 23 | 43 | 24-4-2013 456 | 23 | 43 | 28-4-2013 123 | 23 | 43 | 28-4-2013
i want imei of particular user date 5-4-2013 25-4-2013 doin this:
select imei user_name='a' , date_of_allocation>='5-4-2013' , date_of_deallocation<='25-4-2013';
and want data of user table b. how can that.
select imei of user date date,then data of imei user table b
you can use subquery in form
select * b imei in ( select imei_no .... )
you can use joining
select * left join b on (a.imei_no = b.imei) ...
http://dev.mysql.com/doc/refman/5.0/en/join.html
there many possible options, depending on particular application, size of tables etc.
Comments
Post a Comment