Solved

sql sentence

Posted on 2016-11-30
2
8 Views
Last Modified: 2016-11-30
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 49

Accepted Solution

by:
Ryan Chong earned 500 total points
Comment Utility
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
Comment Utility
thank you so much
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now