Click to See Complete Forum and Search --> : How to use DISTINCT operator


akrashdi
11-18-2005, 11:05 AM
Hi,

Question # 1
I'm trying to print mailing label from my web form. I'm pulling records form database and I have families in there. I don't wanna pring label for each and every person in family, instead I wanna print just one label for the whole family. I have same phone number for every family member in the database. How to use DISTINCT to pull one label for the entire family?

I wanna pull, name & address.


Question # 2

How to maintain margins when printing web pages, I think this is something about CSS thing

Regards,

Tim158
11-18-2005, 11:39 AM
1) Can't just use SELECT * FROM families WHERE surname='???' LIMIT 1?

2) Margins depend on printer settings but page margins can be made more accurate by using CSS as follows:

html {
margin: 0;
}

body {
margin: 0;
}

Ubik
11-18-2005, 12:34 PM
SELECT * from addresstable where phonenumber in (select distinct phonenumber from addresstable)

akrashdi
11-19-2005, 06:51 PM
I tried following statement but it shows me all the records not the DISCTINCT ones

"SELECT customer_profile.customer_id, customer_profile.first_name, customer_profile.middle_name, customer_profile.last_name, customer_profile.phone, customer_profile.email_address, customer_profile.address, customer_profile.city, customer_profile.state, customer_profile.zipcode, package_details.package_id, package_details.leader_id, package_details.leaving_date FROM customer_profile INNER JOIN package_details ON customer_profile.customer_id = package_details.customer_id WHERE package_details.package_status='Ok' AND customer_profile.phone in (SELECT DISTINCT customer_profile.phone FROM customer_profile)"

akrashdi
11-20-2005, 10:50 AM
waiting for a kind reply.

akrashdi
11-20-2005, 11:12 AM
I tried following statement but it shows me all the records not the DISCTINCT ones

"SELECT customer_profile.customer_id, customer_profile.first_name, customer_profile.middle_name, customer_profile.last_name, customer_profile.address, customer_profile.city, customer_profile.state, customer_profile.zipcode, package_details.package_id FROM customer_profile INNER JOIN package_details ON customer_profile.customer_id = package_details.customer_id WHERE customer_profile.phone in (SELECT DISTINCT customer_profile.phone FROM customer_profile)"