Before I attempt to answer your question, let me try to educate you a bit in basic database terminology, as you seem to have trouble grasping some of it.
In a normal database - MySQL included - there are databases, table, columns, rows, cells, and values in those cells.
A database and table should be quite explanatory. A column is vertical, and represents a data type.
A row is one horizontal line of data, and contains one cell for each column in the current table.
A table's structure is defined through its columns. A table's data is defined through its rows.
I don't really understand what you mean by "display 1 data".
Nonetheless, here is a basic MySQL query:
Code:
SELECT column_name FROM table_contacts WHERE column_age = 12;
Ok, so let's break it down.
I want to get data from the
table_contacts.
I want to only display
column_name, located in
table_contacts.
I want to only display
column_name if that same row of data also has
column_age equal to 12.
So, essentially, what I am going to get from this is all my contacts' names who are 12 years old. This query will return only one column, because I am only selecting
column_name, but it will return one or more rows, because I want to see everyone's name if they are age 12. (
WHERE column_age = 12)
Now, let's get a bit more advanced. Let's say that I want to display the name of my youngest contact. So, only one. Well, that'll look something like this:
Code:
SELECT column_name FROM table_contacts ORDER BY column_age ASC LIMIT 1;
Ok, now we have some fancy stuff at the end of this query.
ORDER BY column_age - This tells the query that it is going to order my results by age, instead of the default(usually ID, but depends on the table).
ASC - This tells the query that it is going to do the above
ORDER BY using ascending. You can use either ascending or descending (ASC or DESC). Ascending is essentially the oldest(integer/datetime)/the smallest(integer)/the earliest(datetime). Descending is the opposite - it sorts by the newest(datetime)/the biggest(integer).
LIMIT 1 - This tells the query that it is only going to return one result. Even if there are more than one results available, it will only return one (the first that it finds).
I hope this helps clear some stuff up.