aggitan aggitan - 2 months ago 5
MySQL Question

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?

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.

Comments