Search fields in multiple tables

Results 1 to 2 of 2

Thread: Search fields in multiple tables

  1. #1
    Join Date
    Dec 1969

    Default Search fields in multiple tables

    i have a 3 tables, and a form that has fields to search all 3 tables, how can i construct sql statement to do the search,<BR><BR>eg: form variables<BR>name - in table1<BR>age - in table2<BR>gender - in table3<BR><BR>how can i construct sql statament to do the search?

  2. #2
    Nils Bilhorn Guest

    Default RE: Search fields in multiple tables

    It depends. Are your tables related in any way? If so<BR><BR>select * from t1,t2,t3<BR> where =<BR> and =<BR> and = &#039;Nils&#039;<BR> and t2.age = 22<BR> and t3.gender = &#039;Female&#039;<BR><BR>Or if they are they disparate you can use a union query provided that the select list are equal<BR><BR> select t1.c1,t1.c2 from t1 <BR> where = &#039;Nils&#039;<BR> union <BR> select t2.c2,t2.c3 from t2<BR> where t2.age = 22<BR> union<BR> select t3.c3,t3.c4 from t3<BR> where gender = &#039;Female&#039;<BR><BR>The select lists must be identical with regard to cardinality and type.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts