By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,271 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,271 IT Pros & Developers. It's quick & easy.

Help! MySQL LEFT JOIN probelm in Perl

P: 2
Hi All

I have a sticky problem! Its a LEFT JOIN sql statement which works fine in MySQL but not when called in Perl. Any ideas?

I have 2 tables: campaigns & companies. I'm trying to join them so that all columns of both tables are returned when 2 fields match across the tables and some additional tests in the first table. It works fine in MySQL but returns an empty set when called in Perl. Is there some limitation in Perl or a better way to format the command for it to work from Perl?

Here is the SQL statement which works fine when tried directly inside MySQL:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM campaigns 
  2. LEFT JOIN companies 
  3.   ON campaigns.DestinationURL=companies.Website 
  4. WHERE (
  5.   campaigns.BudgetAvailable>0 
  6.   AND campaigns.SearchWebs LIKE "%google%"
  7. ORDER BY campaigns.MaxPayPerClick DESC LIMIT 6
And here is the Perl code:
Expand|Select|Wrap|Line Numbers
  1. my $query = qq{ SELECT * FROM campaigns LEFT JOIN companies ON campaigns.DestinationURL=companies.Website WHERE (campaigns.BudgetAvailable>0 AND campaigns.SearchWebs LIKE "%$website%") ORDER BY campaigns.MaxPayPerClick DESC LIMIT 6 };
where $website has the variable passed into it.

Please help me if you can!!!

Thanks.
Feb 18 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.