Home > database >  MySQL query
MySQL query

Time:10-10

Request output all the information in the oldest boy, I used the command can only query the oldest person all of the information, combined with sex='male' complains, table structure is as follows, please great god guide

CodePudding user response:

 create table # a 
(
Studentno char (11),
Sname varchar (8),
Sex varchar (4),
Birthday date
)
Insert into # a

Select '18122210009', 'Xu Dongshan' and 'male', '1999-11-05' union all
Select '18122221324', 'what the millennium', 'female' and '2000-12-04 s' union all
Select '18125121107', 'worship hengjiang' and 'male', '2000-03-01' union all
Select '18125121107', 'liang a reed', 'female' and '1999-09-03 s' union all
Select '19120000111', 'Korea mountains and rivers' and' male ', '2000-02-05'

Select the top 1 datediff (year, birthday, getdate ()) as the maximum age, *
The from # a
Where sex='male'
The order by the maximum age desc

I am using is essentially, results and you don't know how, but I'm not an error

CodePudding user response:

Or an error, alas, I this is used alone any conditions can, as long as two at the same time with errors

CodePudding user response:

references the original ai, on the second floor response:
or error, alas, I this is can be used alone any conditions, as long as two at the same time with wrong
you why you not put your query posted, a great god so much to show them

CodePudding user response:

if no, I have modified the code, you have already run a success, thank you
  • Related