Selecting a single row in MySQL

后端 未结 3 1227
名媛妹妹
名媛妹妹 2020-12-30 01:03

I am using MySQL, I have a table that has 9 columns. One of them is the primary key.

How can I select a single row, by the primary key or column 8 or 4?

3条回答
  •  孤城傲影
    2020-12-30 01:35

    If I understand your question correctly:

    SELECT * FROM tbl WHERE id = 123 OR colname4 = 'x' OR colname8 = 'y' LIMIT 1
    

    The 'LIMIT' keyword makes sure there is only one row returned.

提交回复
热议问题