2 tables

Results 1 to 3 of 3

Thread: 2 tables

  1. #1
    nek Guest

    Default 2 tables

    I have the following query:<BR><BR><BR>mysql= "SELECT count(classcode) as PageCount, Classcode as BusinessCategory FROM Clients,classes WHERE classes.KWord like &#039;%"& searchtext &"%&#039; and clients.categoryID = classes.catcode GROUP BY clients.classcode"<BR><BR>Basically I want to link 2 tables. One table has the keywords and the other has the results from which the corresponding keywords match. Thereafter I want to group the results according to some other field in the clients database. <BR>I came up with the above code which is not working. I keep getting the error that the parameters are too few. Is there a better way of building this query or what could be the problem?

  2. #2
    Join Date
    Dec 1969

    Default RE: 2 tables

    SOmething like this:<BR><BR>(I&#039;m guessing at your table names)<BR><BR>SELECT count(classes.classcode) as PageCount, classes.Classcode as BusinessCategory FROM classes INNER JOIN clients ON clients.categoryId = classes.catcode<BR><BR>I believe that will give you what your looking for. Unless I misunderstood your question or made a typo ;o)

  3. #3
    Nils Bilhorn Guest

    Default RE: 2 tables

    Does the column classcode appear in both tables? It looks like that when viewing the code. If so you must qualify all occurrences with the table name.

Posting Permissions

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