Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting 1 recored using GET in Complicated Query

Status
Not open for further replies.

blasterstudios

Technical User
Dec 30, 2004
128
US
i have a query setup that works, but now i want to pull info for just record based on value "id" in $_GET. how do i do it?

Code:
$jobid = $_GET['id'];
$query_getcurrentjob = "SELECT
	fox_clients.code AS code,
	fox_jobs.jobid AS jobid,
	fox_clients.name AS client,
	fox_users_employee.firstname AS employee,
	fox_users_originator.firstname AS originator,
	fox_jobs.duedate,
	fox_status.status AS status,
	fox_priorities.prioritylevel AS priority,
	fox_types.type AS jobtype
FROM
	fox_jobs,
	fox_clients,
	fox_users AS fox_users_employee,
	fox_users AS fox_users_originator,
	fox_status,
	fox_priorities,
	fox_types
WHERE
	fox_jobs.jobid = 'jobid',
	fox_clients.clientid = fox_jobs.client AND
	fox_users_employee.userid = fox_jobs.employee AND
	fox_users_originator.userid = fox_jobs.originator AND
	fox_status.statusid = fox_jobs.status AND
	fox_priorities.priorityid = fox_jobs.priority AND
	fox_types.typeid = fox_jobs.jobtype AND
	fox_jobs.status <= 2
ORDER BY fox_jobs.duedate ASC, fox_jobs.priority DESC";
 
Insufficient data for a meaningful answer.

In general, you would include an additional comparison clause in your WHERE block. Unfortunately, only you know enough about the tables and value in question to be more specific.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
the part in the where clause that says
Code:
fox_jobs.jobid = 'jobid',
that is where i want to match the jobid with the URL parameter id, which as at the top
Code:
$jobid = $_GET['id'];
 
Assuming your programming language is PHP, I would use string concatenation.

Replace:

WHERE
fox_jobs.jobid = 'jobid',
fox_clients.clientid = fox_jobs.client AND

With

WHERE
fox_jobs.jobid = " . $_GET['id'] . " AND
fox_clients.clientid = fox_jobs.client AND



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top