MS SQL to MySQL migration - problem

wxdqz

New Member
I am migrating a database and associated PHP scripts from an MS SQL database to a MySQL database. The original author of the scripts has a couple SQL statements that I can't quite wrap my brain around when trying to convert them to what MySQL will accept. I'm hoping someone can help me with this:

In MS SQL, the statement is:

select userid, fname + ' ' + lname AS name FROM users WHERE owner = " . $HTTP_SESSION_VARS["session_useri
d"] . " or pchar IN (SELECT userid FROM users WHERE owner = " . $HTTP_SESSION_VARS["session_userid"] . ") order by pchar,name

I just can't seem to fathom what I can do to produce the same result in MySQL. I've got the concat(fname, ' ', lname), but the pchar IN nested select is tripping me up. Is there anyway to solve this?

The second MS SQL statement that is giving me a major headache is a bit more complicated:

SELECT item_id,name FROM items WHERE (slots & " . $spot . ") = " . $spot . " and ((race & (SELECT race FROM users WHERE userid = " . $thisuser . "))>0) and ((class & (SELECT class FROM users WHERE charid = " . $thisuser . ")
)>0) ORDER BY name

As you can see, this statement is fairly complext, and again, with nested selects. Does anyone have a clue how I might do the same thing in MySQL?

Thank you for any help.
 
Back
Top