Forums

PHP

This topic is locked

Easy Question-Filtered Recordsets Multiple

Posted 02 Mar 2007 08:34:17
1
has voted
02 Mar 2007 08:34:17 Emily F posted:
Hi,

I'm sort of intermediate with Dreamweaver and I want to filter a recordset by a URL parameter AND an entered value

so far my Advanced Recorset Dialogue looks like this:

SELECT *
FROM producers_pro INNER JOIN allcrew ON idper_pro=id_per
WHERE idfilm_pro = colname
WHERE kindofproducer_pro = 'Executive Producer'

I know I can't just put two 'WHEREs' back to back....I feel like this might be really simple & I just don't know.

THANKS!
Emily

Replies

Replied 02 Mar 2007 12:23:36
02 Mar 2007 12:23:36 Roddy Dairion replied:
thats not gona work. you can have only 1 where.
<pre id=code><font face=courier size=2 id=code>
select * from producers_pro inner join allcrew on idper_pro = id_per and idfilm_pro = colname where kindofproducer_pro = 'Executive Producer'
</font id=code></pre id=code>
This should do the trick
Replied 02 Mar 2007 18:23:39
02 Mar 2007 18:23:39 Emily F replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
thats not gona work. you can have only 1 where.
<pre id=code><font face=courier size=2 id=code>
select * from producers_pro inner join allcrew on idper_pro = id_per and idfilm_pro = colname where kindofproducer_pro = 'Executive Producer'
</font id=code></pre id=code>
This should do the trick
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Thank!

For some reason I had convinced my self that MYSQL would allow me to filter by both a url parameter AND an 'entered value'.

Drat.
Replied 02 Mar 2007 18:34:53
02 Mar 2007 18:34:53 Roddy Dairion replied:
Am not sure i understand can u explain a bit more please.
Replied 02 Mar 2007 19:14:41
02 Mar 2007 19:14:41 Emily F replied:
Well I'm building a page that will show all infomation on a film. All recordsets are filtered by id_film from the table 'film'

When I show a producer I filter from the table 'producers_pro' WHERE the idpro_film=film

But I also want to show only the producers that have nameofproducer_pro='Executive Producer'

I figure I can EITHER do this by filtering by two WHEREs or INNER JOINING three tables (producers_pro (gives the id_film and the id_per), allcrew (gives the name, info, links and bio of the person), and kindofproducer_kin (gives the title of the producer).

The page is like a mini IMNB where you can add a film, ad a person to a film, and edit all information for a unique person that automatically updates for all films that person is added to.

I'm kind of breaking my head over this and any help would be appreciated.

I have a feeling I'm taking the hard way into this, but I'm completely self taught and often take the hardway.
Replied 30 Mar 2007 00:38:05
30 Mar 2007 00:38:05 Kiel Fellow replied:
I Have a similar problem where I need to filter from two fields my current recordset is:

SELECT nc_report.Emp_No, nc_report.NC_Num, nc_report.NC_Description, root_cause.Person_Responsible, root_cause.PCD_day, root_cause.PCD_month, root_cause.PCD_year, root_cause.ACD_day,root_cause.ACD_month, root_cause.ACD_year,root_cause.Solution_Description, verification.VCD_month
FROM nc_report LEFT JOIN root_cause on root_cause.NC_No = nc_report.NC_Num LEFT JOIN verification on verification.NC_No = nc_report.NC_Num
WHERE nc_report.Emp_No = colname
ORDER BY nc_report.NC_Num desc

it is a reporting site where a user logs on and makes reports. this is from the worklist page where it show the employee all the reports that they have done.
but at the moment it only shows reports that the employee have done themselves I also want it to display the records where they are the supervisor or the person responsible
so I really need another WHERE like :

WHERE root_cause.Person_Responsible = colname
Replied 30 Mar 2007 09:34:12
30 Mar 2007 09:34:12 Roddy Dairion replied:
just add AND to your statement for e.g.
SELECT myname FROM names WHERE firstname = 'Roddy' AND sex = 'M'

Display all the firstname Roddy that are male (M)

Reply to this topic