Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

show blank in column if condition not matches in join mysql

Use a LEFT JOIN

SELECT b.id, a.T1
FROM (query1) AS a
LEFT JOIN (query2) AS b ON a.id = b.id

LEFT JOIN means that the result should include all rows from the first table. If there's no match in the second table, all those columns (e.g. b.id) will be NULL in the result, but it will still show the columns from the first table.
You can slao use RIGHT JOIN, which reverses the roles of the first and second tables.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #show #blank #column #condition #matches #join #mysql
ADD COMMENT
Topic
Name
3+8 =