We are building a linux application that uses aMySQL database. The code is written in C++, but we'd prefer that simple table queries all by MySQL. The two below queries need joining into a single one to lessen processor calls by half.
we have two tables as described:
table 1. Object_name. ID (object
id), IND (the number of the name for the object) and VALUE (the actual name) Several names can be valid for one object id, the IND shows what name number is for any given object ID.
table 2. Replicas ReplicaNUM and ObjectNum.
ID and ObjectNUM for anygiven object are identical.
the two queries are:
SELECT DISTINCT object_name.id FROM
object_name WHERE value = 'somestring'
and
SELECT replica.id FROM replica WHERE mother
= object_id_gained_from_1st_query AND id > number_passed ORDER BY (id) LIMIT 1
the effect is to take an object name {of which there may be any number for a given object_id, and find out what the lowest matching replica number is for the object id.
can anyone give me the sql query that would put both parts into one call?
we have two tables as described:
table 1. Object_name. ID (object
id), IND (the number of the name for the object) and VALUE (the actual name) Several names can be valid for one object id, the IND shows what name number is for any given object ID.
table 2. Replicas ReplicaNUM and ObjectNum.
ID and ObjectNUM for anygiven object are identical.
the two queries are:
SELECT DISTINCT object_name.id FROM
object_name WHERE value = 'somestring'
and
SELECT replica.id FROM replica WHERE mother
= object_id_gained_from_1st_query AND id > number_passed ORDER BY (id) LIMIT 1
the effect is to take an object name {of which there may be any number for a given object_id, and find out what the lowest matching replica number is for the object id.
can anyone give me the sql query that would put both parts into one call?