views:

44

answers:

6
Select COUNT(*) as num t1.id,t1.ads_city,t1.ads_title,t1.ads_description,t1.ads_location,t2.ads_date,t2.ads_image,t2.ads_id,t2.ads_time,t2.postads_id ,t2.ads_url 
  FROM postads t1 
  JOIN nextpostads t2 ON t1.id = t2.postads_id 
 WHERE t2.ads_activate="Yes" 
   AND t1.ads_type="offerring" 
   AND t1.ads_category="Learning & Education" 
   AND t1.ads_city="kolkata" 
ORDER BY t2.ads_time DESC

I am getting an error message

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.id,t1.ads_city,t1.ads_title,t1.ads_description,t1.ads_location,t2.ads_date,t2' at line 1

what about this error ?

A: 

You are missing a comma after:

COUNT(*) as num 
Travis Beale
A: 

In your query, you have this portion :

Select COUNT(*) as num
t1.id,

You have to put a comma (,) after num, like there is after the other selected fields :

Select COUNT(*) as num, 
t1.id,
...
Pascal MARTIN
A: 

You need to put a comma after "as num"

Kerry
+1  A: 

You're missing a comma and some quotes.

A: 

It's hard to tell from the formatting here, but you may be missing a comma b/t num and ti.id

sparkey0
A: 

Verify with simplified code: SELECT COUNT(*) AS NUM t1.id FROM test t1;

To make it a valid syntax:

  1. Remove the t1.id to make it a valid syntax

  2. Add comma before t1.id

ttchong