close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

DA SEARCH Query

Thread began 9/29/2010 10:10 am by Cologne | Last modified 10/07/2010 2:42 pm by Jason Byrnes | 2087 views | 22 replies |

Cologne

DA SEARCH Query

Hello,

I need some help with my search result page.

I created my searchform: suchen.php

Instruments and genre are created from DA manage related tables.

Will say, I store all the Instruments and Genres a Member wants in an extra Table profileInstruments & profileGenre.

Then I got 2 tables for the instruments and genre themself.

And I got a table for the profile itself.

So, if someone searches a GUITARIST that plays ROCK and lives in COLOGNE(city)

How do I filter that.

SELECT profile.profileID, profile.nickname
FROM profile, instruments, genre
WHERE ????

I dont know how to start.


Am I right, that I need a final recordset, that shows all possibilities of my results? I created a recordset, that contains only nickname, and postcode. but in the wizard all fields of the table are shown.

Or is this recordset only to show the results?

Sign in to reply to this post

Jason ByrnesWebAssist

in the profile table should be linked to the instrument and genre tables using a foreign key

on the search page, you would create select list to chose the instrument or genre.

the select list will show the name, but set it to pass the ID as the value.

then you can search on the foreign key ID value in the profile page.


see the w3sachools page for more details on related tables in SQL:
sql_join.asp

Sign in to reply to this post

Cologne

Hi Jason,

I cant store the InstrumentID and GenreID in the Profile table, cause I stored all instruments and genres in an extra table, so no instrument or genre is double.

What I did is...

I created an table called profileInstruments and profileGenre that stores only the foreignkeys (InstrumentID / ProfileID and GenreID / ProfileID)

I my searchform I created 2 lists, from profileInstruments and profileGenre, so I got all instruments and genres that are available.

No my problem is, to unit all there 5 tables to get a search result with DA-Search.

Genre, Instrument, Profile, ProfileInstruments and ProfileGenre

I dont know how to crate, that recordset, so I can make a search.

Denis

Sign in to reply to this post

Jason ByrnesWebAssist

navicat is a good tool for generating complex join queries using visual GUI:
mysql_overview.html

Sign in to reply to this post

Cologne

I dont understand that.

so, I will put all information into one table so i can use the DA search.

thanks so far,
denis

Sign in to reply to this post

Jason ByrnesWebAssist

no, you need to start with a complex joined query recordset that pulls the data from all of the related tables.

the navicat tool i linked to is a good tool fro creating the recordset for you if you do not wish to learn the SQL syntax for creating such a query.

Sign in to reply to this post

Cologne

thanks jason,

i downloaded it and tried the query builder. i dont get any result i need to.

I made a recordset so far. the Search runs like I want but could be better:

search.php

SELECT DISTINCT
`profile`.profileID,
`profile`.`name`
FROM
`profile`
INNER JOIN profilegenre ON `profile`.profileID = profilegenre.profileID
INNER JOIN profileinstruments ON `profile`.profileID = profileinstruments.profileID



I want to add, the INSTRUMENTS and GENRE to the result.

But when I try my way, then I get double results on every instrument and every genre :-(

SELECT
`profile`.profileID,
`profile`.`name`,
`profile`.plz,
`profile`.city,
genre.genre,
instruments.instrument
FROM
`profile`
INNER JOIN profilegenre ON `profile`.profileID = profilegenre.profileID
INNER JOIN profileinstruments ON `profile`.profileID = profileinstruments.profileID
INNER JOIN genre ON genre.genreID = profilegenre.genreID
INNER JOIN instruments ON instruments.instrumentID = profileinstruments.instrumentID



is there a way to put all instruments and all genres into one field, or something?

Sign in to reply to this post

Cologne

Jason,

I made it :-)

SELECT DISTINCT
`profile`.profileID,
`profile`.`name`,
`profile`.plz,
`profile`.city,
GROUP_CONCAT(DISTINCT genre.genre) AS genre,
GROUP_CONCAT(DISTINCT instrument.instrument) AS instrument
FROM
`profile`
INNER JOIN profilegenre ON `profile`.profileID = profilegenre.profileID
INNER JOIN profileinstruments ON `profile`.profileID = profileinstruments.profileID
INNER JOIN genre ON genre.genreID = profilegenre.genreID
INNER JOIN instrument ON instrument.instrumentID = profileinstruments.instrumentID
GROUP BY
`profile`.profileID
ORDER BY
`profile`.plz ASC



Cause I got the instrumentID field double, I needed to customize the DA search wizard into profileinstrument.instrumentID :-)

I am so happy that it works!

thanks for your help!

denis

ps. maybe in DA update it would be cool that it automatic choose the right table :-)

Sign in to reply to this post

Jason ByrnesWebAssist

ok, glad to hear you got it working.

Sign in to reply to this post

Cologne

Hi Jason,

what does DA search, the field itself or the field after the recordset?

cause one of my fields ist just a date 1972-04-13 but the recordset transforms it to the age in years. 38

(YEAR(CURRENT_DATE) - YEAR(profile.age)) - (RIGHT(CURRENT_DATE,5) < RIGHT(profile.age,5)) AS age



will it compare to 38 or DATE?

Denis

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...