0

i have two table for article and setting. in article table i put id,title,date ..etc and in settings table, i have row with name featuredarticle and put id of article with separate comma for featured articles. now i need to list/print my featured article only. how to ?

TABLE articles:

ID | TITLE | DATE | PUBLISH
1
2
3
4
5

TABLE settings / row featuredarticle:

1,2,5

enter image description here

1
  • 2
    You will need to add some additional detail here. How far do you get? Do you have a working MySQL query? Are you getting any error messages? etc. Commented Jan 15, 2013 at 9:53

3 Answers 3

1
SELECT  a.*
FROM    articles a
        INNER JOIN settings b
            ON FIND_IN_SET(a.ID, b.featuredarticle) <> 0

If you have time to change the table schema, change it. It is a bad design to have columns vith value separated by a comma.

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

3 Comments

i see this error : Error 1054: Unknown column 'b.featuredarticle' in 'on clause'. i now this bad design, but i custom the any modules of cms And I have no choice.
@BaTmaN how come you have an unknown column? can you post the result of this query please, DESC articles and DESC settings
sorry but, i dont care how to work DESC articles and DESC settings query! can u tell me how to work this?
0

Get data from DB to array and use:

$newArray = explode(".", $dataDbArray);

Comments

0

You can try this-

SELECT * FROM article
     JOIN settings ON FIND_IN_SET( id, featuredarticle)

Please have a look at demo: demo

2 Comments

LEFT JOIN is not needed here, the OP states i need to list/print my featured article only
@SureshKamrushi : i see this error: Error 1054: Unknown column 'featuredarticle' in 'on clause'. i add screen of options table. please see this.

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.