Knex js How to apply union on 2 tables which has different number of columns
I have 2 tables with diff columns as shown below
- Table - A Columns
Name, Age, Gender, email_id
- Table -B Columns
course, course_type, university
- How to convert below mentioned query in Knexjs
SELECT NAME, EMAIL_ID, NULL AS COURSE, NULL AS UNIVERSITY FROM TABLEA UNION SELECT NULL AS NAME, NULL AS EMAILID, COURSE, UNIVERSITY FROM TABLEB
1 answer
-
answered 2022-05-03 10:02
user2710786
I tried below mentioned knex js query but getting error
- Knexjs query
myDB .select('NAME', 'EMAIL_ID', {'NULL':'COURSE'}, {'NULL':'UNIVERSITY'}) .from('TABLEA') .union(canonDB.select({'NULL':'NAME'},{'NULL':'EMAILID'}, COURSE',UNIVERSITY}).from('TABLEB'))
- Error :
Unknown column 'NULL' in 'field list'
How many English words
do you know?
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
how many words do you know
Powered by Examplum