Results 1 to 5 of 5

Thread: SQL TABLE Section

  1. #1
    JUDE ### Guest

    Default SQL TABLE Section

    Hi,<BR><BR>Can you please let me know how I could add another table name to pick data from to the following SELECT statement. Database is Access and the two tables are ocstbl and namtbl<BR><BR>("SELECT <BR>ocstbl.CWB,ocstbl.DATE,ocstbl.RNAME,ocstbl.TIM E,ocstbl.SDATE from ocstbl WHERE ocstbl.CWB LIKE &#039;%" & SearchText & "%&#039;")<BR>

  2. #2
    Tim Snyder Guest

    Default RE: SQL TABLE Section

    ("SELECT <BR>ocstbl.CWB,ocstbl.DATE,ocstbl.RNAME,ocstbl.TIM E,ocstbl.SDATE, namtbl.&#060;field&#062; from ocstbl, nametbl WHERE ocstbl.CWB LIKE &#039;%" & SearchText & "%&#039;")<BR>

  3. #3
    David Tremayne Guest

    Default RE: SQL TABLE Section

    Woah Man! No No No, You got it all wrong.<BR>If you want to cross reference tables you don&#039;t do it that way!<BR><BR>Example:<BR><BR>"Select T1.Col1,T1.Col2,T2.Col3,T2,Col4 From Table1 T1, Table2 T2"<BR>Notice after the table name I put something like a key word for referencing the tables like T1, T2.<BR>You have to do it like that.<BR><BR>And if you want to do a ORDER BY clause your are still going to have to use the T1, Or T2.<BR><BR>But You can&#039;t have 2 col names the same when you display these in your asp they&#039;re gonna have to be put down without the T1 Or T2.<BR><BR>:p<BR>~Dave<BR>~16YrOldN00bFromCanada

  4. #4
    Join Date
    Dec 1969

    Default What if both table has one unique field ?

    Hello,<BR><BR>Thanks for your help, I would like to ask you how could I select what I search from one table and relation to that to select the other fields from the second table, which should be equal to the numbers I am seaching and then to list out the fields.<BR><BR>Eg. I enter 123 and this is a unique field in Table 1 and then with relation to this it should select the other fields from Table2. in Table2 123 is also there but I do not want to list it again.<BR><BR>Please help me.<BR><BR>Thanks<BR><BR>Jude<BR><BR><BR><BR><BR>

  5. #5
    Join Date
    Dec 1969

    Default RE: What if both table has one unique field ?

    I think you should look at JOINS. either in the FAQs or http://www.learnasp.com/learn/dbjoin.asp. Or using the id:<BR><BR>SELECT *<BR>FROM prod_cat AS c, prod_list AS p<BR>WHERE c.id = p.pid;<BR><BR>or<BR><BR>SELECT [prod_cat].[id], [prod_cat].[pid]<BR>FROM prod_cat<BR>WHERE (((prod_cat.pid)=(SELECT pid FROM prod_cat WHERE id=29)));<BR><BR>using your table names etc.<BR><BR>HTH<BR><BR>Mark<BR>

Posting Permissions

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