> I really need some help. I'm trying to use an IF statement in a multi-table
> left join. I'm joining four tables (customers, contents, courses &
IF can only be used in the select part or the where part, it can't be
used in the join part of a query.
> In the contents table I have two fields, product_id and value_id that relate
> to different values in different tables depending upon the value in the
> product_type field. If product_type='course' then the product_id and
> value_id relate to the courses and locations table, but if
> product_type='other' then the product_id and value_id relate to the product
> and prices table.
> I have two options:
> 1. Match only the courses and locations where product_type='course' and
> NULL values if relating to the product and prices table.
> 2. Or change the query (and fields) if the product_type='other' to use the
> product and prices table.
You can union the results.
select ... where product_type='course'
select ... where product_type='other'
> I'm using Mysql 4.3.
Didn't know there was such a version ;)
Postgresql & php tutorials
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php