Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:52:38+00:00 2026-05-30T09:52:38+00:00

i have three tables i would like to link in this one query. The

  • 0

i have three tables i would like to link in this one query.

The script is an attendance register, so it records an attendance mark for each meeting, per user.

The three tables used:

“team”:

id | fullname | position         | class | hidden
1  | Team     | --               | black | 1
2  | Dan S    | Team Manager     | green | 0
3  | Harry P  | Graphic Engineer | blue  | 0

“register”:

id | mid | uid | mark
1  | 1   | 2   | /
2  | 1   | 3   | I
3  | 2   | 1   | /
4  | 2   | 3   | /

“meetings”:

id | maintask            | starttime  | endtime
1  | Organise Year Ahead | 1330007400 | 1330012800
2  | Gather Ideas        | 1330612200 | 1330617600
3  | TODO                | 1331217000 | 1331222400

There is a sample of the data. What i want to do is:

Select all the results from the register, group them by the user, and order them by the meeting start time. But, if there is not a mark in the register table, i want it to display “-” (can be done via php if needed) So an expected result like so:

fullname | mark | mid
Dan S    | /    | 1
Dan S    | /    | 2
Dan S    | -    | 3
Harry P  | I    | 1
Harry P  | /    | 2
Harry P  | -    | 3

My SQL Query is this at the moment:

SELECT u.fullname,u.id,r.mark,r.mid FROM team u FULL JOIN register r ON r.uid=u.id LEFT JOIN meetings m ON
r.mid=m.id GROUP BY u.id ORDER BY m.starttime ASC

And i get an error back from MySQL:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘FULL JOIN register r ON r.uid=u.id LEFT JOIN meetings m
ON r.mid=m.`id’ at line 1

But, i cant see an issue with it :S

Please could someone help out, point me in the right direction or give me a possible solution to this. Much Appreciated

Dan

Answer:
Query that worked:

   SELECT     
       u.fullname,    u.id as uid,    
       if(r.uid = u.id, r.mark, '-') as mark,    
       if(r.uid = u.id, r.mid, '-') as mid,    
       r.mid,    m.starttime 
   FROM     
       team u 
         CROSS JOIN     
       register r ON u.id = r.uid
         LEFT OUTER JOIN     
       meetings m ON r.mid = m.id  
   WHERE    
       u.hidden = 0 
   GROUP BY     
       u.id, r.mid 
   ORDER BY     
       m.starttime, u.id ASC
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:52:39+00:00Added an answer on May 30, 2026 at 9:52 am

    Full outer join is not supported by MySQL. At least to version 5.6, you can check MySQL Join doc. A cross join may be a workaround:

    EDITED

    SELECT 
       UxM.fullname,
       r.mark,
       UxM.mid,
       UxM.starttime
    FROM 
       ( select u.id as uid, m.id as mid, u.fullname, m.starttime
         from
         team  u
          CROSS JOIN   
         meetings ) UxM
       left join
       register r
          on UxM.uid = r.uid and UxM.mid = r.mid
    ORDER BY 
       UxM.starttime ASC
    

    Let me know if this solve your issue.


    A simplification:

    SELECT     
        u.fullname,
        u.id AS uid,    
        COALESCE(r.mark, '-') AS mark,    
        COALESCE(r.mid, '-') AS mid,    
        m.id,
        m.starttime 
    FROM     
        team u 
          CROSS JOIN     
        meetings m 
          LEFT JOIN     
        register r
            ON   r.mid = m.id  
            AND  r.id = u.uid
    WHERE    
        u.hidden = 0 
    GROUP BY     
        m.id, u.id 
    ORDER BY     
        m.starttime, u.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following three tables: alt text http://img16.imageshack.us/img16/5499/linqtosqlquery.jpg With LinqToSql I would like
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables. This query will write down the right answer (x-lines for
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
My goal is to get a query written. I have three tables, A, B
I have three tables tag , page , pagetag With the data below page
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three tables in my DB (actually a few more than that) these
I have three tables A: A.pID primary key, A.Name nvarchar(250) B: B.pID primary key,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.