Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

RE: [clug-support] Mysql Script

From: Justin L. Spies <jspies(at)rentalcondos.com>
Date: Sat Jan 25 2003 - 07:04:32 EST


Brian,
I posted this message on Thursday, however I never saw it go through, so I'm reposting it.

Brian,
Although not entirely efficient, you should be able to use the following:

SELECT
 GradYr,
 GradLastName,
 GradFirstName,
 CurrLastName,

 IF(hideinfo = 'N', Address, '') AS Address,
 IF(hideinfo = 'N', City, '') AS City,
 IF(hideinfo = 'N', State, '') AS State,
 IF(hideinfo = 'N', Zip, '') AS Zip,

 hideinfo
FROM psh_alumni
WHERE State = 'colname';

Note that this is, as others have pointed out, not valid SQL'92 syntax and is
probably not portable across database platforms. It will work under MySQL. Each database engine tends to have it's own implementation, for example you can
use the CASE statement to check for multiple values if you are running MS-SQL
Server. If you need to check for null values, you would use the following in MySQL:
  IFNULL(expr1, expr2)

while in MS-SQL Server, you would use:
  ISNULL(expr1, expr2)

For details about the immediate if command in MySQL (the IF(...)), see the following URL:
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Con trol_flow_functions

Hope that this helps...

Sincerely,
Justin L. Spies

Do you need help?X

-----Original Message-----
From: owner-clug-support@cleveland.lug.net [mailto:owner-clug-support@cleveland.lug.net]On Behalf Of Brian Speck Sent: Wednesday, January 22, 2003 9:54 PM To: clug-support@cleveland.lug.net
Subject: [clug-support] Mysql Script

I am wondering if someone could look at this script and see if it is even in the right ballpark to work..

SELECT GradYr, GradLastName, GradFirstName, CurrLastName, Address, City, `State`, Zip, hideinfo
FROM psh_alumni
WHERE State = 'colname'
If hideinfo = 'y'

   Begin

      (Address = ' ',
      City = ' ',
      State = ' ',
      Zip = ' ' )

I AM really novice at this. But I would think something like that should work. However when I run that scrip I get an SQL syntax error. Basically I am making an alumni site that if the person wants his Address withheld then it will not show up, the only thing that will show us is his/her name and Grad Year.

Can someone please help me, or point me in the right direction?

TIA Brian Speck

-*-*-

This message brought to you by the CLUG Support mailing list. CLUG Support is for all Linux support as needed by CLUG members. To unsubscribe: email to majordomo@cleveland.lug.net with the body: unsubscribe clug-support
OTHER CLUG MAILING LISTS:

clug-talk		-- For all general CLUG discussions
clug-announce	-- For announcements about upcoming CLUG events
And don't forget our website: http://cleveland.lug.net/
Do you need more help?X

-*-*-

This message brought to you by the CLUG Support mailing list. CLUG Support is for all Linux support as needed by CLUG members. To unsubscribe: email to majordomo@cleveland.lug.net with the body: unsubscribe clug-support
OTHER CLUG MAILING LISTS:

clug-talk		-- For all general CLUG discussions
clug-announce	-- For announcements about upcoming CLUG events
And don't forget our website: http://cleveland.lug.net/ Received on Sat Jan 25 07:18:27 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 12:41:10 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library