1

i have the following two tables 1st table is students

--------------------------------------------------------------------
| tag_id   |     name   | colloge     |  department| class  |dev_id|
|----------+------------+-------------+------------+--------+------|
| 00000022 | Jhon Rayan | Engineering |  Computer  | first  | c01  | 
--------------------------------------------------------------------

2nd table is called lecture_table

--------------------------------------------------------
| dev_tag| lecture_name| lecturer_name|  start | end   |
|--------+-------------+--------------+--------+-------|
| c01    | Math I      | Jhon Simone  |  08:30 | 10:30 | 
--------------------------------------------------------

So i need to make a query by tag_id(00000022) in students table and get full information about it from students table.then compare this student through (dev_id) with lecture_table (dev_tag) to get the lecture associated to this student only from whole lecture_table i tried to use this query but didn't work

    $raw_results = mysql_query("SELECT s.tag_id
    s.dev_id,
    s.name,
    s.colloge,
    s.class,
    lt.lecture_name
    ,lt.lecturer_name,
    lt.dev_tag,lt.day,
    lt.start,lt.end,
    FROM students s INNER JOIN lecture_table lt ON s.dev_id = lt.dev_tag WHERE s.tag_id LIKE '%".$query."%' AND(`name` LIKE '%".$_SESSION['username']."%')")  or die(mysql_error());

so any one can help??

2
  • 1
    The solution seems to be correct only a few syntactic failures there are, like a , before FROM statement or missing , after s.tag_id Commented Jul 28, 2014 at 11:08
  • are getting some error?? would you mind posting the error. Commented Jul 28, 2014 at 11:09

1 Answer 1

1

Modify your query as

$raw_results = mysql_query(
     "SELECT s.tag_id, s.dev_id, s.name, s.colloge, s.class, 
         lt.lecture_name ,lt.lecturer_name, lt.dev_tag,lt.day,
         lt.start,lt.end
       FROM students s JOIN lecture_table lt ON s.dev_id = lt.dev_tag 
       WHERE s.tag_id LIKE '%".$query."%' 
         AND(`name` LIKE '%".$_SESSION['username']."%')")  
      or die(mysql_error());

Remove , before From keyword and place a , after SELECT s.tag_id

Sign up to request clarification or add additional context in comments.

1 Comment

OK its work now my friend am so annoyed cause i didn't see (,) in my query and i will submit your answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.