Thread: using output of a subselect in LIKE/ILIKE
Hi folks, <p>I need to do something like : <p><tt>SELECT branch from branches</tt><br /><tt>where outstation like</tt><br/><tt>SELECT city from users join personal_account_details</tt><br /><tt>using(userid) where email='ratans@cal.vsnl.com'</tt><tt></tt><p>Theabove does not work for obvious reasons , but can anyone help me <br />withthe right SQL? <br /> <p>regds <br />Rajesh Kumar Mallah. <br /> <br /> <br />
SELECT branch from branches where outstation like (SELECT city from users join personal_account_details using(userid) where email='ratans@cal.vsnl.com') || '%' --- Rajesh Kumar Mallah <mallah@trade-india.com> wrote: > Hi folks, > > I need to do something like : > > SELECT branch from branches > where outstation like > SELECT city from users join > personal_account_details > using(userid) where email='ratans@cal.vsnl.com' > > The above does not work for obvious reasons , but > can anyone help me > with the right SQL? > > > regds > Rajesh Kumar Mallah. > > > > __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/
thanks Jeff it worked ! after adding a '%' || after LIKE though :-) WORKING SQL: SELECT branch from branches where outstation ilike '%' || (SELECT city from users join personal_account_details using(userid) where email='ratans@cal.vsnl.com') || '%'; Jeff Eckermann wrote: > SELECT branch from branches > where outstation like > (SELECT city from users join > personal_account_details > using(userid) where email='ratans@cal.vsnl.com') || > '%' > > --- Rajesh Kumar Mallah <mallah@trade-india.com> > wrote: > > Hi folks, > > > > I need to do something like : > > > > SELECT branch from branches > > where outstation like > > SELECT city from users join > > personal_account_details > > using(userid) where email='ratans@cal.vsnl.com' > > > > The above does not work for obvious reasons , but > > can anyone help me > > with the right SQL? > > > > > > regds > > Rajesh Kumar Mallah. > > > > > > > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Tax Center - online filing with TurboTax > http://taxes.yahoo.com/ > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org