Jump to content

extreme query returning unexpected results


michaellunsford

Recommended Posts

I'm doing a FULLTEXT search across four tables. Some tables have certain fields that others do not, so to get around the "wrong column count" errors, I added [color=blue]'' AS `field_name`[/color] to those queries who were missing that field.

For example:

[code]
(SELECT `pages_per_minute`,`paper_trays`,'' AS `processor`, '' AS `hard_drive`,'printers' AS `table_name` FROM `printers`)
UNION
(SELECT '' AS `pages_per_minute`,'' AS `paper_trays`,`processor`, `hard_drive`, 'computers' AS `table_name`FROM `computers`)
[/code]

What's weird, I get the occasional weirdo response:

[0]['pages_per_minute'] = 225
[0]['paper_trays'] = 2 trays
[0]['processor'] =
[0]['hard_drive'] =
[0]['table_name'] = printers

[1]['pages_per_minute'] =
[1]['paper_trays'] = [b]250 Gigabyte[b]
[1]['processor'] = Intel
[1]['hard_drive'] = 250 Gigabyte
[1]['table_name'] = computers

I'm really scratching my head on this one, though. So any insight would be awesome.
Link to comment
Share on other sites

no, that's the real output (and the problem). Here is the output again, in code tags to make it a little cleaner.

[code]
[0]['pages_per_minute'] = 225
[0]['paper_trays'] = 2 trays
[0]['processor'] =
[0]['hard_drive'] =
[0]['table_name'] = printers

[1]['pages_per_minute'] =
[1]['paper_trays'] = 250 Gigabyte
[1]['processor'] = Intel
[1]['hard_drive'] = 250 Gigabyte
[1]['table_name'] = computers
[/code]
Link to comment
Share on other sites

weird... I reverse it and it works fine. Wonder what's up with that

By the way, duplicating the query in phpMyAdmin does the same thing: one way, it "creates" data (apparently based on another record in the same row), the other way, the data seems accurate (at least for the same 9 records it returns).
Link to comment
Share on other sites

I gave a simplified example to simplify the nuances of the different tables -- printers and computers are pretty easy in this crowd  :)

Anyway, you can download the tables (with contents) [url=http://www.virtual-showcase.net/mls_lafayette.sql.zip]here[/url] (it's about 1.2 megabytes)

You can perform a search on the test-site [url=http://new.realestatedela.com/residential.html]here[/url]. To reproduce the results search for [color=blue]breaux bridge[/color]. The second match is the culprit: L06134084.

The problem is it's a commercial property that's returning bedrooms. And there isn't even a bedrooms field in that table. Reveal source and you can easily find the SQL query tucked inside HTML comments, and a little further down, I'm print_r()ing the entire $row.
Link to comment
Share on other sites

New information:
1. I've acheived the same error using a different search method. I can pull up the same record by searching by just the number: [color=blue]L06134084[/color]. The difference is the number search doesn't use MATCH() AGAINST() and it's still producing the same results.

2. phpMyAdmin. I've run the search a dozen different ways. Basically, if I put residential in front of commercial, the bedrooms get "created" from one of the [color=blue]square foot[/color] fields -- even if eliminate all the other tables.

If anyone has been ambitious enough to try loading the database and duplicating the search, I'd be very curious to know if you get the same results. PS, I'm running MySQL 4.1.21
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.