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

Asked

Viewed 81 times

2

Considering the table, 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? inserir a descrição da imagem aqui

  • 1

    Hello user, do you have a specific DBMS in mind or is this a theoretical question? (If you have a specific DBMS in mind edit your question by adding a tag).

  • 1

    I already edited it. It’s Mysql.

  • @Stell do not forget to see the [tour] to understand the mechanism of the site. You can vote on the answers that helped you in some way and accept the answer that was the best in each question you asked.

2 answers

5

Assuming the table name in question is "myTable":

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

Command tested in Mysql 5.5.

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

4

SELECT * FROM table WHERE LastName = 'Duck' AND BirthDate > DATE('1950-01-01');

Where table is the table name. See * will show all fields, if you want something specific, replace * by the name of the desired field. Note that the date format in the command must be equal to the format of the Birthdate field.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.