Hi all, I am using MySQL 4.1.11nt I have two MyISAM tables:
Table 1 holds usage information about users accessing various parts of the database. Relevant fields are "Users_Code", "Users_action" and "Affected_Member". Table 2 holds personal information about the Member. Relevant fields are "Member_Code", "Member_Surname" and "Member_Groupname" Table1.Affected_Member is the link to Table2.Member_Code. Table1.Affected_Member can be a null field. My application is coded so that if Table2.Member_Surname is null, there will be a string value in Table2.Member_Groupname. The reverse is also true. The application is also coded so that Table2.Member_Surname and Table2.Member_Groupname cannot both be null, nor both have a value. I am trying to code the following: 1. If Table1.Affected_Member is not null, then get Table2.Member_Surname where Table1.Affected_Member = Table2.Member_Code, assigning this to the output of the query as Member_Name. 2. If Member_Name is not a string then let Member_Name = Table2.Member_GroupName This will give the result that if Table1.Affected_Member is not null, then the returned value of Member_Name will be either the Surname of the Member or the Groupname of the Member. Although I am having success with coding part 1. of the query, I cannot get Part 2 of the query to give the required result. I can take the resultset from just running a query to get the information from table 1, and then go through this result set, running further queries to get the information required from Table 2, but, as I see it, this will have to be a new query for each record in the Table1.Resultset, which will take up a lot of bandwidth, and make the application slow. Is it possible to code this into one single query that returns all of the values required? Many thanks for your help! Martin -- -------------------------------------------------- [EMAIL PROTECTED] -------------------------------------------------- This email, and any attachments, has been scanned for virus contamination using Norton Anti-Virus 2002 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]