richard
richard

Reputation: 547

How to select a function as well as select from table

If I have a table tb with some data, say:

A   B 
__|__
1 | 1
2 | 2

Is there a way to do a SELECT * FROM tb along with a select of a function, say SELECT NOW() and end up with something like:

1 | 1 | datetime
2 | 2 | datetime

Or if it's any different, SELECT * FROM tb WHERE A=1 and SELECT NOW() to give

1 | 1 | datetime ?

Upvotes: 0

Views: 41

Answers (1)

ajreal
ajreal

Reputation: 47321

Yes, like :-

select A, B, now() as some_column_name from tb;

Or :-

select A,B from tb
inner join (select now()) as date_time
where A=1;

Upvotes: 1

Related Questions