Solved

sql sentence

Posted on 2016-11-30
2
39 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 50

Accepted Solution

by:
Ryan Chong earned 500 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

778 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