Skip to content

SQL IF statement query #2

@tourniquet

Description

@tourniquet

Right now, because of my SQL knowledge are very limited, I am using a query to JOIN price currency to the item with an empty/NULL title, but I am looking how to use an IF statement to have something like:
IF item.currency_id != 0 THEN JOIN
ELSE do something else

So, right now, the query looks like this:

SELECT ads.*, sub.title AS subcategory, cat.title AS category, currency.title AS currency
FROM cls_ads AS ads
INNER JOIN cls_categories AS sub ON ads.subcategory_id = sub.id
INNER JOIN cls_categories AS cat ON sub.parent_id = cat.id
INNER JOIN cls_currencies AS currency ON ads.currency_id = currency.id
WHERE ads.url = " . $_GET['url'];

and I need to modify the last INNER JOIN.
If you know how to fix this, please feel free to create a pull request.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions