mysql - add an extra column while select from two tables -


i have 2 tables me, web , mail. using query fetch data both tables.

preparedstatement ps = con.preparestatement("(select * web name='abc') union (select * mail name='abc')"); resultset rs = ps.executequery(); while(rs.next()){       bw.write(rs3.getstring("name")+"~"+rs3.getstring("age")+"~"+rs3.getstring("profession"); bw.newline(); } 

the output this.

+------+------+------------+ | name | age  | profession | +------+------+------------+ | abc  |   20 | doctor     | | abc  |   20 | engineer   | +------+------+------------+ 

and in file this

abc~20~doctor abc~20~engineer 

but how can add column in result set give me data in format

abc~20~doctor~web abc~20~engineer~mail 

select * , 'web' source web name='abc' union select *, 'mail' source mail name ='abc' 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

debian - 500 Error upon login into Plesk Admin - auth.php3? -