Hi,
In a representative table, I have fields, like, id, mark_id, rep_id rep_name, father name,etc,
In this table, rep_id field is empty,
And in rep_area table, the fields are like id, rep_id, dist_id,etc, in this table, rep_id has values.
While editing the representative form i want to display rep_id from the rep_area table. Hopw to do?
I need the query.

Member Avatar for diafol
SELECT rep_id, some_other_unique_descriptive_field FROM rep_area ORDER BY some_field

I'm assuming you want to build a select (dropdown) form field for this.

If you wish to match both table, make sure there are some unique keys for the tables to match to each other.
select representative.id, representative.mark_id, representative.rep_name, representative.father_name, representative.etc, rep_area.id, rep_area.rep_id, rep_area.dist_id, rep_area.etc from representative,rep_area where rep_area.id = representative.id;
This query is generated based on assumption that both table's id is the same.

Thanks to both of you

I am new to MYSQL and i love it. creating tables and querries are still problem.please help me.Am from Uganda

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.