which SQL command would display the records where the LastName field is "Duck" and the date in the BirthDate field is greater than 01/01/1950?

2

Given the table, what SQL statement would display the records where the LastName field is "Duck" and the date in the BirthDate field is greater than 01/01/1950?

    
asked by anonymous 30.08.2014 / 01:36

2 answers

5

Assuming the name of the table in question is "myTable":

select
  *
from mytable
where lastname = 'Duck'
  and birthdate > '1950.01.01'

Tested command in MySQL 5.5.

Note: Whenever possible, I recommend formatting the command. For extended commands this custom is essential to avoid wrong constructions and to facilitate maintenance.

    
30.08.2014 / 02:07
4
SELECT * FROM table WHERE LastName = 'Duck' AND BirthDate > DATE('1950-01-01');

Where table is the name of the table. Note that * will show all fields, if you want something specific, replace * with the desired field name. Note that the date format in the command must be the same as the BirthDate field format.

    
30.08.2014 / 02:12