如何在mysql中选择2倍的位置?

时间:2021-05-08 11:22:55

I have a table with destionations PRN, SKP, MUC etc.

我有一张桌子,上面有PRN, SKP, MUC等。

I want to select 15 rows with the destionation PRN and SKP, but I am not sure how to do this because when I write down

我想要选择15行带有destionation PRN和SKP,但我不知道该怎么做,因为当我写下来的时候。

SELECT * FROM destinations WHERE date >= NOW() AND destination = 'PRN' OR 'SKP'

it wont work it will show only where SKP or only where PRN, I have tried this with OR, AND adn so on.. but I cant a way that works and selects 15 last destinations where destionation = PRN and SKP.

它只会显示SKP或者PRN的位置,我已经尝试过了,还有adn等等。但是我不能用一种方法来工作,选择最后的15个目的地,在那里destionation = PRN和SKP。

6 个解决方案

#1


3  

you can use as :

你可以用as:

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination = 'SKP')

or use IN operator

或使用操作符

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN','SKP')

and for only 15 row you can add " LIMIT 15" after query

而对于只有15行,您可以在查询后添加“限制15”。

#2


1  

SELECT * FROM destinations WHERE date >= NOW() 
AND (destination = 'PRN' OR destination='SKP')
ORDER BY date desc LIMIT 15

#3


0  

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN', 'SPK')

or

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination =  'SPK')

should do the trick

应该足够了

#4


0  

Using in is generally the most readable form (especially if you have multiple destinations):

使用通常是最易读的形式(特别是如果您有多个目的地):

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ( 'PRN' , 'SKP' )

When using or, be sure to put brackets around the second term so its clear which operator is applied first:

在使用或使用时,请务必将括号括在第二项上,以使其清楚地使用哪个操作符:

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination = 'SPK')

#5


0  

The correct syntax is:

正确的语法是:

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination = 'SKP')

Or:

或者:

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN', 'SKP')

#6


0  

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN' , 'SKP')

#1


3  

you can use as :

你可以用as:

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination = 'SKP')

or use IN operator

或使用操作符

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN','SKP')

and for only 15 row you can add " LIMIT 15" after query

而对于只有15行,您可以在查询后添加“限制15”。

#2


1  

SELECT * FROM destinations WHERE date >= NOW() 
AND (destination = 'PRN' OR destination='SKP')
ORDER BY date desc LIMIT 15

#3


0  

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN', 'SPK')

or

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination =  'SPK')

should do the trick

应该足够了

#4


0  

Using in is generally the most readable form (especially if you have multiple destinations):

使用通常是最易读的形式(特别是如果您有多个目的地):

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ( 'PRN' , 'SKP' )

When using or, be sure to put brackets around the second term so its clear which operator is applied first:

在使用或使用时,请务必将括号括在第二项上,以使其清楚地使用哪个操作符:

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination = 'SPK')

#5


0  

The correct syntax is:

正确的语法是:

SELECT * FROM destinations WHERE date >= NOW() AND (destination = 'PRN' OR destination = 'SKP')

Or:

或者:

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN', 'SKP')

#6


0  

SELECT * FROM destinations WHERE date >= NOW() AND destination IN ('PRN' , 'SKP')