View Full Version : Search Results getting messed up with INNER JOIN
terencepjf260961
07-01-2009, 09:12 PM
Hi; I built the search results pages with DA and then modified the SQL to use an inner join to get more meaningful info to display in the results view.
I had to alias 2 fields, but the search fails when I select either of these options... centerid and contact
http://www.affordable-commerce-solutions.com/admin/contactinstores_search.asp
The issues are:
1) Selecting either the centerid or contact give me a 500 error
2) The Default Store checkbox behaves strangely (the field is a char & I tried several combinations of default values
3) How do I get ALL the results without selecting any search criteria?
Modified SQL ...
SELECT dbo.contactinStores.id as ID, dbo.GPCWebViewCust1.CustName, dbo.contact.name, dbo.contactinStores.centerid as centerid, dbo.contactinStores.contactid as contactid, dbo.contactinStores.defaultstore as defaultstore
FROM dbo.contact INNER JOIN dbo.contactinStores ON dbo.contact.contactid = dbo.contactinStores.contactid INNER JOIN dbo.GPCWebViewCust1 ON dbo.contactinStores.centerid = dbo.GPCWebViewCust1.CenterID
Thanks in advance
Ray Borduin
07-02-2009, 07:17 AM
1) Probably because those column names you are filtering with aren't unique in the query. Try updating the code by hand to use contactinStores.centerid and contactinStores.contactid and it will probably fix that problem.
2) it isn't a checkbox now... You may have adjusted the page so I'm not sure if you are still having issues with this portion.
3) this should be the default functionality. I think you aren't getting all the results because of your last select field not having the correct option value for the first option:
<select name="S_defaultstore" id="S_defaultstore">
<option selected="selected">All</option>
should be:
<select name="S_defaultstore" id="S_defaultstore">
<option value="" selected="selected">All</option>
terencepjf260961
07-02-2009, 12:59 PM
Thanks Ray; I have tried and re-tried most of today with no luck! I used diffreent alias but the DA Search dialog always selects BOTH fields and defaults the type to List.
I tried qualifying the field as you suggested and it does not filter the recordset.
I tried using a different alias name - the recordset shows the right alias, but DA Search still brings in the table fields.
It seems to me that DA Search does not consider the alias name and pulls in the unqualified field names instead.
What do you recommend I do in this case?
Thanks
Ray Borduin
07-02-2009, 01:08 PM
Please post a support incident. Somebody will need to look into it further with you.
terencepjf260961
07-04-2009, 04:41 AM
Thanks Ray; your post for the INNER Join and Russell's pointers for the checkbox worked - finally! after 3 days of playing around with the DA Search feature - so many gotcha's !!
It was a good learning experience though.
Just to highlight the areas:
1) Alias your tables and TEST out the raw SQL
2) Run the default DA wizard
3) Update your search page - checkboxes and/or Radio groups (I did the radio group only because I could set the checked/unchecked defaults or default your database column to N|0
4) Update your results page Recordset - paste your aliased SQL code and TEST - note the column name if you have aliased those too!
5) Update your DA Search - this is the crux of the problem; if you have 2 key fields like I did with the same name - BOTH will be selected and this will not work. Also make sure the COLUMN TYPE and Filter TYPE are correctly selected for your search needs
6) Modify the DA Search code (BuildFromList) parameters to reference the ALIASED fields - VERY IMPORTANT!
7) Modify the form fields to reference the aliased columns too
Thanks again to Ray & Russell
info315909
10-13-2009, 09:38 PM
Hi, I am having almost the exact same issue as was described in this thread - Inner joins and DataAssist Search not playing together.
Could you please open a support ticket for me to resolve the issue. (Was not enough detail in the final post to determine how the issue was actually resolved).
DataAssist Version: 2.0.6
Ray Borduin
10-14-2009, 07:28 AM
I have gone ahead and opened up a support incident for you. Please update it with a good phone number and time to call.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.