[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

sql sentence

Posted on 2016-11-30
2
Medium Priority
?
80 Views
Last Modified: 2016-12-28
Dear Experts,

I need to add where clause to below sql statement. I use PHP and mysql

I'd like to add WHERE a.onay='1' to the sql statement  (  onay coloumn is on the first table )

where should I add it? I added it before LIMIT clause, but it didn't work.

$sql9 = "SELECT a.id, a.sehir, a.uid, a.baslik, a.kategori, a.fiyat, a.icerik, a.telefon, a.sontarih, a.onay ,b.ilanid ,b.resim
FROM ilan a  
LEFT JOIN
(
    SELECT ilanid, MAX(resim) resim
    FROM resimler
    GROUP BY ilanid
	DESC
)b ON a.id = b.ilanid LIMIT $start_from, $per_page";

Open in new window

0
Comment
Question by:Braveheartli
2 Comments
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 41908266
try:

$sql9 = "SELECT a.id, a.sehir, a.uid, a.baslik, a.kategori, a.fiyat, a.icerik, a.telefon, a.sontarih, a.onay ,b.ilanid ,b.resim
FROM ilan a  
LEFT JOIN
(
    SELECT ilanid, MAX(resim) resim
    FROM resimler
    GROUP BY ilanid
      DESC
)b ON a.id = b.ilanid  WHERE a.onay='1' LIMIT $start_from, $per_page";
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 41908269
thank you so much
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question