Skip to content
Advertisement

Selecting a single row in MySQL

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?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement