aggitan aggitan - 1 year ago 106
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download