I've a simple query which returns me list of ids..
eg. select id from users;
this returns me the list of ids, but I need another x column(not for the users table or any other table in db) with some constant value which I'll give. I can achieve that with Js or other language after querying the ids. But just need to know if there's any way to do it within the query itself.
current result:
id
---
1
2
3
expected result:
id some_new_column
--- ---
1 abc
2 abc
3 abc
where some_new_column and abc, both should be provided in query.
Not sure if this is even possible or not. Any leads/helps appreciated.
Just add the literal value to the select clause:
select id, 'abc' as some_new_column from users
You just select it:
select id, 'abc' as new_column_value
from t;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With