Author Topic: Issue with Custom Query in User Selection  (Read 1458 times)

chufford

  • Posts: 34
    • View Profile
Issue with Custom Query in User Selection
« on: January 10, 2007, 09:56:22 am »
I created a complex custom query in the user selection area.
Code: [Select]
left join lm_users as B on lm_users.email = B.email and lm_users.uid != B.uid WHERE lm_users.cnf=1 AND  (lm_users.list = 4 or lm_users.list = 6 or lm_users.list = 8 or lm_users.list = 9) AND (B.email is NULL or B.list =4 or B.list =6 or B.list =8 or B.list =9) group by lm_users.email
This query selects everyone on list 4,6,8 & 9 who are not on other lists and groups by email to remove duplicates. (The people on the other lists will get a different email but I don't want anyone to get 2 emails). The above query was too long and the end was truncated when I saved it. I notcied that the 'q' field in Table lm_selectd was 'TinyText'. I changed that to 'Text' and the query was stored correctly.

Testing the query in the User Selection worked perfectly. However, when I went to actually send the message, there was a query error. It said that 'email' was an ambiguous field. Line 440 of selfunc.php does a condition between selecting '*' or selecting 'email,id'.  In my query, there are duplicate fields so that 'email' is ambiguous. I temporarily changed that line 440 to 'lm_users.email, lm_users.id' and then the whole thing worked.

I am not sure if you want to change this, but I wanted to let you know. Also, the above query might be helpful to others who are trying to accomplish a similar thing. This query may address this post:
http://listmailpro.com/forum/index.php?topic=1440.0

Thanks.
Chris Hufford

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Issue with Custom Query in User Selection
« Reply #1 on: February 25, 2007, 06:57:09 pm »
Hi Chris,

The line has been changed for the next update and all future updates.
Quote
if($rxmode=='send') $selstr = "$utable.email,$utable.id"; else $selstr = '*';

The size of the custom query field will also be updated:
Quote
// increase size of field holding 'custom sql' user selection queries
 "ALTER TABLE $sedtable CHANGE q q TEXT NOT NULL",

Best
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting