Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

USE INDEX (PRIMARY) in mysql query, but getting a wrong syntax error?

Tags:

mysql

I'm trying to speed up a mySQL query by making it use the index, but for some reason it's telling me that the syntax is wrong. I can't figure out why, though. Any ideas?

All I did was add "USE INDEX (PRIMARY)"

SELECT a.listing_id FROM db_listings USE INDEX (PRIMARY)
a LEFT JOIN db_users u ON u.user_id=a.owner_id WHERE a.active=1 GROUP BY a.listing_id
like image 258
user1227914 Avatar asked Oct 29 '25 16:10

user1227914


1 Answers

Put the table alias a before the USE INDEX clause.

like image 86
Joe Avatar answered Oct 31 '25 06:10

Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!