Home > database >  Jump for the SQL statement
Jump for the SQL statement

Time:03-03

Table a
The create table a
(
Id int,
The name varchar (50),
Je money,
Primary key (id)
)
Table b
The create table b
(
Ikey int,
Id int,
The name varchar (50),
Je money,
Primary key (iKey)
)

Insert a
Select 11, 'onion', 4.0
Union select 22, garlic, 7.0
Union select 33, 'ginger', 3.0


Insert b
Select 1, 2, 'garlic, 5.8
Union select 2, 22, 'garlic, 4.8
Union select 3, 2, 'garlic, 6.2

In the lookup table, a judge if there is a same id in the table b is tasted, if you have the lowest prices displayed if no is still shows a table price, the final query result
11, the 'green', 4.0
22, garlic, 4.8
33, 'ginger', 3.0
  • Related