hi all i have search engine like that:

sql = "SELECT * FROM ads WHERE ad_country='7' and approve='1' and ad_name LIKE '%iphone%' or ad_country='7' and approve='1' and ad_content LIKE '%iphone%' ORDER BY ad_date DESC LIMIT 0,30";

and it's work great but it is too long.

are there any sample way or another easy format?
thanks.

Recommended Answers

All 3 Replies

ok I found this:
sql = "SELECT * FROM ads WHERE ad_country='7' and approve='1' and (ad_name LIKE '%iphone%' or ad_content LIKE '%iphone%') ORDER BY ad_date DESC LIMIT 0,30";

is that the sample way or there is another thanks.

What do you mean with "too long"? Does the query take to long? Add indexes to the fields ad_country and approve.

ok I found this:
sql = "SELECT * FROM ads WHERE ad_country='7' and approve='1' and (ad_name LIKE '%iphone%' or ad_content LIKE '%iphone%') ORDER BY ad_date DESC LIMIT 0,30";

is that the sample way or there is another thanks.

I guess this(the second query you have written) is the optimized form of query, that you were wishing to have. You can carry out with this. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.