views:

26

answers:

3

I want to join 2 tabls with id. I wrote following query but i am getting an error. I want to select all columns simultaneously in mysql.

select t1.* t2.* table1t1 
  JOIN table2t2 
    ON t1.id = t2.postads_id 
where ads_id=1277719543 
  AND email='[email protected]';

ERROR: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1 JOIN nextpostads t2 ON t1.id = t2.postads_id where ads_id=1277719543 AND emai' at line 1

what modification is needed ?

+4  A: 

There is a comma missing between t1.* and t2.* and there is no FROM clause:

SELECT t1.*, t2.*
  FROM table1 t1 
  JOIN table2 t2 
    ON t1.id = t2.postads_id 
 WHERE ads_id = 1277719543 
   AND email = '[email protected]'

Also, try sticking to either uppercase of all keywords or lowercase, but not mixing it.

inflagranti
Query Solved Thanks to all :)
saurav
If that solved it you should accept it as the right answer. As should you do for most of your other questions. This way, people will know which is the correct answer to a question (and that it has one correct answer).
inflagranti
A: 

You are missing the FROM in your statement. Try:

select t1.*, t2.* 
FROM table1 t1 
  JOIN table2 t2 
    ON t1.id = t2.postads_id 
where ads_id=1277719543 
  AND email='[email protected]';
Jan_V
SELECT t1. * t2. * FROM postads t1JOIN nextpostads t2 ON t1.id = t2.postads_idWHERE ads_id =1277719543AND email = '[email protected]'LIMIT 0 , 30MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '. * FROM postads t1 JOIN nextpostads t2 ON t1 . id = t2 . postads_id where ads_i' at line 1 I am getting now this error..
saurav
A: 
select t1.*, t2.* FROM table1 t1 
  JOIN table2 t2 
    ON t1.id = t2.postads_id 
where t1.ads_id=1277719543 
  AND t1.email='[email protected]';
Salil