Francisco Tapia
fhtapia at gmail.com
Fri Jan 30 23:25:49 CST 2009
Jean Paul, You'll want to define your where criteria... that is: SELECT * FROM contacts AS ctc WHERE NAME = 'Criteria' this way the results are what you expect To join two tables you will want to associate the corresponding fields Such as: SELECT * FROM contacts AS ctcs INNER JOIN contacts_organization_types AS cot ON ctcs.ID = cot.id WHERE ctcs.name = 'Criteria' some interesting things are happening here... first I have used a table alias that's where you see the table name contacts followed by the keyword AS then an abbreviation of my liking (no reserved words) such as ctcs so I 'm telling the engine that I will from that point on substitute the use of ctcs whenever it expects to see an explicit reference for the table name contacts. Also if you take a look at the criteria, you'll notice that I have a field name in there the name I took from your example but it should be any valid name in your table that you want to search against... saying WHERE 1 is a true statement, but does not reflect the case of WHERE id = 1, so you may want to revise your select statement. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Fri, Jan 30, 2009 at 8:58 PM, jean-paul <jnatola at hotmail.com> wrote: > > Hi all, > > So I was attempting to for the first time to get data using the select > statment > > here was my first syntax > SELECT * FROM `contacts` WHERE 1 > > it returned all the records (as I wanted) 9050 records > contact name address emaill etcc.. > now there is another table called contacts_organization_types > I wanted the corresponding output to come out in the same query > > so i tried this > SELECT * FROM `contacts`,`contacts_organization_types` WHERE 1 > > now i got the same results as above- but instead of it adding the field > to the list it returned each record from the contacts with every single > cust_org_types for example > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > first statement results; > > id first name last name email > 1 jp natola > > > second statment results; > > > > id first name last name email organaization type > 1 jp natola NGO > > > 1 jp natola MED > > 1 jp natola Donor > > 1 jp natola Education > > 1 jp natola Media > > How do i modify the statement to just give me the record with the actual > value that is in the contacts record > > thanks > > > > > > > > > > _________________________________________________________________ > Hotmail(R) goes where you go. On a PC, on the Web, on your phone. > > http://www.windowslive-hotmail.com/learnmore/versatility.aspx#mobile?ocid=TXT_TAGHM_WL_HM_versatility_121208 > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > >