help with a SQL script?
Hello,
I am very much a beginner with SQL, and I was hoping for some help with a script.
I need to pull records from a table with distinct values for one of the fields and a given value for another field. I want the results to include all of the fields.
In other words…I need a combination of:
select * from tableABC where name = ‘Scott’
&
select distinct ProductName from tableABC
Thanks for any help.
Try the following SQL statement:
SELECT DISTINCT tableABC.Name,
tableABC.Product
FROM tableABC
WHERE (((tableABC.Name)="Scott"));
The DISTINCT should only pull unique values for the Product, but allow every instance of Name = Scott.
This is different than using the DISTINCTROW.
Though I would probably have never created a relational database where these two fields were within the same table. They would have been two separate tables, connected by a Join on some Unique Key.
Try the following SQL statement:
SELECT DISTINCT tableABC.Name,
tableABC.Product
FROM tableABC
WHERE (((tableABC.Name)="Scott"));
The DISTINCT should only pull unique values for the Product, but allow every instance of Name = Scott.
This is different than using the DISTINCTROW.
Though I would probably have never created a relational database where these two fields were within the same table. They would have been two separate tables, connected by a Join on some Unique Key.
References :