inosent1 wrote:Code: Select all
$query="SELECT DISTINCT file_id , * , FROM data1_c";
// or ...
$query="SELECT DISTINCT file_id , * FROM data1_c";
// or ...
$query="SELECT DISTINCT file_id * FROM data1_c";
results in this warning:
Code: Select all
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean
Well the 1st and 3rd queries above are certainly invalid. Commas are used
between fieldnames in a field list, never after the last one and they are mandatory.
That warning isn't generated by that line, what it is saying is that the mysql_num_rows() functions 2 lines below that can't return the number of rows because the mysql_query() function didn't generate a valid "resource" (which means that either the connection to the database was unsuccessful or the query was invalid). That's certainly true for the 1st and 3rd queries you show because they are, themselves, invalid. I wasn't sure if the comma followed by an asterisk was valid and I didn't take the time to check the manual (always the best thing to do), but you should do what I said earlier, list the fieldnames you need rather than use the asterisk. So if the fieldname is 'last_name', your query needs to be:
Code: Select all
$query="SELECT DISTINCT file_id, last_name FROM data1_c";
inosent1 wrote:
i am not sure what you mean by referring to the same thing, but the db has 100 records, notations
but each notation refers to a specific client (file_id is the identifier)
20 clients, 100 notes, 5 notes per client
what i want is to pull just the names of the clients, w/o duplicates. i am assuming if i say 'pull all the records, but make sure not to show records where file_id duplicates' would work that there is some code snippet that will do that. i just cant figure it out
i dont want to display records where the file_id is the same as another display, just unique file_id and the associated column content from the requested row
i hope that was a little clearer ....
I am referring to how relational databases work. They are not like spreadsheets where you may repeat data if it should be displayed more than once. In your example, every line where the name was 'Smith', the file_id was '7', and the same for the other names. It looked/looks like both 'name' and 'file_id' refer to the same thing. In a relational database that's called a one-to-one relationship--if the file_id is '7', then the name is 'Smith'. That calls for 2 tables, one for peoples' names and the other that relates a person's name with their file_ids. However, this has nothing to do with the problem you are having with the query. I don't want to confuse the 2 issues for you. This is just normal database theory. Indeed, I don't know understand what the colors are related to, so I can't begin to explain how your database should be designed. From your examples the colors appear not to be related to either the name or the file_id. If this is an actual application, rather than a programming exercise, you should not proceed further until you get your database schema straightened out. If it's just a learning exercise, you should take careful note that it's not at all a practical one, or certainly doesn't seem to be, and if you want to gain any practical knowledge from it, you need to study a little bit about relational databases. There's a ton of material on the web about relational databases.