UPDATE
now I can make it work by remove ORDER BY... not sure that's the right thing to do but have to.
First of all,This is all fields(columns) in all table I want to join in the database
and the field in highlighted is the field i want to select.
So, I wrote sql syntax to join all table like this
SELECT country_policies.policyname,
country_policies.countryname,
section_data_structure.data_name,
section_data_content_p.dropname,
section_data_content_p.comment,
date_format(section_data_content_p.start_date,'%Y-%m-%d') as start_date,
date_format(section_data_content_p.end_date,'%Y-%m-%d') as end_date,
section_data_content_p.policy_id,
section_data_content_p.country_id,
sections_content.section_id,
sections_content.statecode
FROM
(
(country_policies
INNER JOIN section_data_content_p
ON country_policies.policyid = section_data_content_p.policy_id AND
country_policies.countryid = section_data_content_p.country_id
)
INNER JOIN section_data_structure
ON section_data_content_p.data_structure_id = section_data_structure.id
INNER JOIN sections_content
ON section_data_content_p.state_id = sections_content.statecode
)
order by section_data_content_p.dropname;
then I got this error
ER_TOO_BIG_SELECT: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
So I tried to add SET SQL_BIG_SELECTS= 1 ; to the top like this
SET SQL_BIG_SELECTS= 1 ;
SELECT country_policies.policyname, country_policies.countryname, section_data_structure.data_name, section_data_content_p.dropname, section_data_content_p.comment, date_format(section_data_content_p.start_date,'%Y-%m-%d') as start_date, date_format(section_data_content_p.end_date,'%Y-%m-%d') as end_date,section_data_content_p.policy_id,section_data_content_p.country_id,sections_content.section_id,sections_content.statecode
FROM ((country_policies
INNER JOIN section_data_content_p ON country_policies.policyid = section_data_content_p.policy_id AND country_policies.countryid = section_data_content_p.country_id)
INNER JOIN section_data_structure ON section_data_content_p.data_structure_id = section_data_structure.id
INNER JOIN sections_content ON section_data_content_p.state_id = sections_content.statecode) order by section_data_content_p.dropname;
then I got an error again
ER_PARSE_ERROR: 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 'SET SQL_BIG_SELECTS= 1 SELECT country_policies.policyname, country_policies.co' at line 1
also tried SET SESSION/ SET OPTION but all not work and I still can't solve this. mysql version is 5.6.32
anyone can help? thanks