开发者

MYSQL select from where except some LINE

开发者 https://www.devze.com 2023-02-17 02:08 出处:网络
I have a basic question: how to make a mysql query that query all the table but except line 8 and line 13?

I have a basic question: how to make a mysql query that query all the table but except line 8 and line 13?

select * from tabl开发者_如何学Ce where //BUT VALUE NOT IN LINE 8 AND LINE 13.(ID=8 AND ID=13)



id|name
1 | a
2 | b
3 | c
4 | d
5 | e
6 | f
7 | g
8 | h // except line 8
9 | i
10| j
11| k
12| l
13| m // except line 13
14| n


Try NOT IN:

SELECT col1, col2, ..., coln
FROM yourtable
WHERE id NOT IN (8, 13)


select * from table where 
id !=8 AND id != 13


Assuming that "LINE 8" and "LINE 13" correspond to primary key values, your query would look like this:

SELECT * FROM myTable WHERE ID NOT IN (8,13)


SELECT * FROM table WHERE ID <> 1

<> is "not equals" in mysql.

Goodluck.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号