Home mysql 2 SQL queries, with the most elderly sellers. And later the other...

2 SQL queries, with the most elderly sellers. And later the other buyer to withdraw from other customers names

Author

Date

Category


Answer 1

The first sample of vendors by the city name, sorted by age would look like this:

select
   s.Name, s.Years, c.City
  from
   Sellers s
  left join
   City c
  ON.
   c.CityID = s.CityID
  where
   c.City = 'city'
  order by s.years desc - if the field is the age of years
- order by s.years asc - and if this is the year of birth as

The second sample, if I correctly understand the conditions will be such:

select
 b.Name
from
 Buyers b
left join
 ([Buyers shops] bs, Shops s)
ON.
 (Bs.BuyersID = b.BuyersID and s.ShopsID = bs.ShopID)
where
 s.ShopsID in (
select
 bs1.ShopID
from
 [Buyers shops] bs1
left join
 Buyers b1
ON.
 bs1.BuyersID = b1.BuyersID
where
 b1.name = 'name of the buyer'
 )

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions