i have this sql query, i know this query is written in bad way, anyone can refine this sql query?
Code:
SELECT column, ship, column, column, column, column FROM tbl_W WHERE id = id AND mid = '' UNION SELECT column, ship, column, column, column, column FROM tbl_W WHERE id = id AND mid IS NULL UNION SELECT column, ship, column, column, column, column FROM tbl_W WHERE d_id = id AND i_sh = '1' order by id DESC
in above query i have a column (ship) it has number values which is ID of another table's (tblShip) record.
now in my sql result i want another column of (tblShip) (column_name) to be returned in place of (ship)[numeric value]