jianneng
07-20-2003, 04:19 PM
Hi, basically I have a database called books. The table (booklist) has a issue_date column (date type). According to MySQL manual, for a date like 2003-07-31, the following query will give a result of '2003':
SELECT EXTRACT(YEAR FROM "2003-07-31");
So I want to write a single SQL query that will show me a list of books issued in 2003.
My initial query looks like this:
$query1 = "SELECT * FROM booklist WHERE (SELECT EXTRACT(YEAR FROM issue_date)=2003) ORDER BY book_no ASC";
Well...syntax error...I could have easily created another column in the table called year alone, but I just want to make my life more difficult with this :D
Thanks in advance.
Lim.
SELECT EXTRACT(YEAR FROM "2003-07-31");
So I want to write a single SQL query that will show me a list of books issued in 2003.
My initial query looks like this:
$query1 = "SELECT * FROM booklist WHERE (SELECT EXTRACT(YEAR FROM issue_date)=2003) ORDER BY book_no ASC";
Well...syntax error...I could have easily created another column in the table called year alone, but I just want to make my life more difficult with this :D
Thanks in advance.
Lim.