Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have two tables:

sendsms with the fields smsID, driverIDS, Responses, driverMobileno
Driver with the fields driverid, name, mobileno

Now I want a query that displays driverid, name, driverMobileno, responses

How do I write this subquery?
Posted
Updated 8-Oct-10 2:44am
v3

You can use INNER JOIN for your query.

like this.

SELECT t1.field1, t1.field2, t2.field1, t2.field2 FROM table1 AS t1 INNERJOIN table2 AS t2 ON ( t1.field1 = t2.field1 );


in which you should have one common fild in both table.

or You can use below one also.

SELECT s.driverid, d.name, s.driverMobileno, s.responses
FROM sendsms AS s, driver AS d
WHERE s.driverid = d.driverid
;


it will give field from both table.
 
Share this answer
 
v3
 
Share this answer
 
Join two tables using JOIN by DriverID

Look Here[^]

And try out yourself. I think that would be good for you to learn.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900