might be something stupid but I need to add the WHERE (i.e. WHERE id=1) clause to this SQL query but i keep gettin error. What is the proper way to implement? Thanks in advance.
The SQL query:
("SELECT i.*,c.fullname
from `invoice_list2` i
inner join impianti_list c
on i.impianti_id = c.id
order by id desc
LIMIT $start1, $limit1");
CodePudding user response:
I found out that I needed to specify from which table I would select the elements using aliases:
SELECT
i.*,c.fullname
from
`invoice_list2` i
inner join
impianti_list c
on
i.impianti_id = c.id
WHERE
i.status=1
order by
id desc
LIMIT
$start1, $limit1
CodePudding user response:
If your query is correct , You can use your result as subquery to filter your records.
select * from (SELECT i.*,c.fullname
frominvoice_list2
i inner join impianti_list c on i.impianti_id = c.id order by id desc LIMIT $start1, $limit1) as tmp where tmp.id = 1