CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Help with sql query

Print topic Send  topic

Author Message
teknofil
Posted: 06/10/2002, 8:22 PM

I have a query which I'm having trouble constructing, and would appreciate any advice or help.

I have two fields I'm populating using a listbox with multiple selection enabled which I'd like to compare and select records where the records have items in common.

eg.

tbl_user
tbl_user.user_group


tbl_article
tbl_article.article_group

tbl_user.user_group has values like 1,3,5,6
tbl_article.article_group has values like 1,3

I thought of using a select statement like;

SELECT * FROM tbl_article WHERE tbl_article.article_group IN tbl_user.user_group

but this doesn't seem to work.

Can anyone help and let me know what I'm doing wrong ?

wonko
Posted: 06/10/2002, 11:35 PM

you should try an INNER JOIN query like this:

SELECT tbl_user INNER JOIN tbl_article ON tbl_user.user_group = tbl_article.article_group WHERE tbl_user.user_group LIKE %1,3%

teknofile
Posted: 06/11/2002, 1:57 AM

Thanks for the response, wonko, but wouldn't that limit me to using known values only, as opposed to variables ?

Could I substitute the LIKE %1,3% with LIKE tbl_article.article_group ? This would allow a much wider range of variables than if I have to hand code each one.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.