There are two table from which i want to get value
1. heads
2. subheads


The field names in heads table is:

id, head_name


the field name in subheads table is:
id,subhead_name.

i want to get value from these two table when the value mean id is '1'

i wrote the query something like this

SELECT `heads.head_name`,`subheads.subhead_name` FROM `heads`,`subheads` WHERE `heads.id` = '1' AND `subheads` = '1'


but its not working please help me guys

What you want is a JOIN

SELECT `heads.head_name`,
`subheads.subhead_name` 
FROM `heads` 
OUTER JOIN `subheads` ON `heads`.id = `subheads`.id 
where `heads.id` = '1'

this selects records from heads where `heads.id` = '1'and joins them to subheads records where `heads`.id = `subheads`.id
Is that what you were trying to do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.