setting up a default value of a column in select statement

abhinav singh picture abhinav singh · Aug 17, 2010 · Viewed 26.4k times · Source

actually i have 2 tables table1 and table2

table1

name
city
addr.

table2

name
city
addr.
ph.no

now ph.no field is an extra field in table 2

so i want to show field ph.no with a default value of 12345 in the output of select query on table1 as i want to append that output into an outfile. help me out ..I am using db2 as400 database

Answer

Mark Byers picture Mark Byers · Aug 17, 2010

Yes, you can do this:

SELECT name, city, addr, 12345 AS ph_no
FROM table1