user2400394
user2400394

Reputation: 91

SELECT and ADD fields in SQL table

I have a db table created as follows :

CREATE TABLE mktDB(
mktID number(19) not null,
featureId number(20) not null,
val varchar(100) not null,
primary key (id)
);

I want to view all the records along with an additional field having current date with each row in the db.

I tried the following sqlite query but it is erroneous :

SELECT *, CURRENT_DATE FROM mktDB,DATE;

Upvotes: 0

Views: 59

Answers (3)

Mitul
Mitul

Reputation: 3427

Please use below query

SELECT *, date('now') FROM mktDB

Upvotes: 1

less
less

Reputation: 711

Don't know SQLite very well but after typing "current date sqllite" in google it shows me the way to https://www.sqlite.org/lang_datefunc.html

and for your problem:

 SELECT *, date('now') FROM mktDB;

P.S: I always wanted to try SQL fiddle. So here it is:

http://sqlfiddle.com/#!7/92fd6/3

Upvotes: 3

Dijkgraaf
Dijkgraaf

Reputation: 11527

1) The function is date('now')

2) You don't need to select from DATE

SELECT *, date('now') FROM mktDB;

Upvotes: 1

Related Questions