sql - combining records from two tables in mysql ordered by date -
i having 2 mysql tables. 1 table "received payments" , "payments made". both tables have of fields common different received payments have additional column of 'baddebt' , on. both tables have date column.
now need generate complete transaction statement these 2 tables datewise. planned using union orderby. not work because number of columns needed same in this.
in case columns differs. should done in situation?
use dummy/placeholder columns.
e.g.
select col1, null col2, col3 table1 union select col1, col2, null col3 table2
use null or appropriate dummy value missing columns.
the 'as" statement used give dummy column name. strictly speaking, believe first select
in union
needs define column names, prefer explicit.
Comments
Post a Comment