1

I have the three MySql tables :

  1. table_fonts

    • font_id (int)
    • font_name (varchar)
  2. table_charsets

    • charset_id (int)
    • charset_name (varchar) (examples: 1=latin, 2=greek, and so on)
  3. table_charsets_by_font

    • font_id (int)
    • charset_id (int)

I am having trouble into creating my INNER JOIN query to obtain a list with all charsets (table_charsets.charset_name) listed in columns, with a value of 1 if existing, or a value of 0 if not existing — aka a TINYINT —, like this :

font_id | font_name | charset_id1 | charset_id1_existing | charset_id2 | charset_id2_existing ... and so on

For example :

1 | Arial           | 1 | 1 | 2 | 1 ... and so on
2 | Arial Black     | 1 | 1 | 2 | 1 ... and so on
3 | Times New Roman | 1 | 1 | 2 | 0 ... and so on

So far, all my attempts have failed. Could someone point me to the right direction ? Thank you :)

0

Please try:

SELECT tf.font_id, tf.font_name, tcf.font_id, tc.charset_name, tcf.font_id, tcf.charset_id  
FROM table_fonts tf 
INNER JOIN table_charsets_by_font tcf ON tcf.font_id=tf.font_id
INNER JOIN table_charsets tc ON tc.charset_id=tcf.charset_id
WHERE tc.charset_name='latin';
2
  • Hi @pankaj-kumar, thanks to proposing me a classic INNER JOIN which is not exactly what I was needing... – AlexLaforge May 23 '18 at 2:40
  • Hi Alex may I get some sample data of tables so that classic INNER JOIN can be converted into needful join.... – Pankaj Kumar May 24 '18 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.