Jump to content


Photo

SQL statement for query


  • Please log in to reply
3 replies to this topic

#1 vickriz

vickriz
  • Members
  • Pip
  • Newbie
  • 2 posts
  • Locationmanila, philippines

Posted 07 August 2003 - 05:14 AM

Good day to all. im using Access2000.
how can i make a query to find the missing records to my second table. tblMaster, tblEncoding has both no ID but they has same fields[ProvinceCode, CityOrMuni, and BarangayName]. any body has idea how can i solve this problem? by the way i have over 100thou records, so its kind a bloddy if i check this manualy..

just really need help. pls..
fun to have internet..

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 07 August 2003 - 08:02 AM

To find the records that are in TableMaster but not in TableEncoding use a LEFT JOIN :-

SELECT m.ProvinceCode, m.CityOrMuni, m.BarangayName
FROM TableMaster m LEFT JOIN TableEncoding e
ON m.ProvinceCode = e.ProvinceCode
AND m.CityOrMuni = e.CityOrMuni
AND m.BarangayName = e.BarangayName
WHERE e.ProvinceCode IS NULL

hth
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 vickriz

vickriz
  • Members
  • Pip
  • Newbie
  • 2 posts
  • Locationmanila, philippines

Posted 08 August 2003 - 04:49 AM

To find the records that are in TableMaster but not in TableEncoding use a LEFT JOIN :-

SELECT m.ProvinceCode, m.CityOrMuni, m.BarangayName
FROM TableMaster m LEFT JOIN TableEncoding e
ON m.ProvinceCode = e.ProvinceCode  
AND m.CityOrMuni = e.CityOrMuni  
AND m.BarangayName = e.BarangayName  
WHERE e.ProvinceCode IS NULL

hth


sorry for being naive but, what does the \'m\' and \'e\' represents??
fun to have internet..

#4 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 08 August 2003 - 06:08 AM

Its called an alias name

say you have a tabled name phpfreak you can create an alias named \"p\" and refer it by that name in the query.

select * from phpfream p where p.name=\"php\"

Alias names are typically used in joins!
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users