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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -