문제

Currently, I have some common tables created and waiting for their respective SELECT queries. (Including their INNER JOIN and LEFT JOIN instances)

I've run into occasions when a Table rarely needs to exist for some databases, but for others it will.

SELECT c.fname, c.lname, c2.colname  
FROM `tbl_cus` c 
 LEFT JOIN `tbl_cus_optional_data` c2 ON c.cusid = c2.cusid 
WHERE 1 

tbl_cus_optional_data will exist on some databases, while others will not. When a database table does not exist MySQL will throw an error, and the query stops, as expected.

Is there way to indicate inside the query if one of the LEFT JOIN tables does not exist, ignore it and any columns in the SELECT portion.

I'm probably searching for a unicorn here, but I get surprised by database capabilities often enough.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top