Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return in select (even in null cases)

Status
Not open for further replies.

tcardoso

Programmer
Jan 31, 2005
56
PT
Hi,

I want do make something like this:

select ta1.* from table1 ta1, table2 ta2 where ta1.field=ta2.field and ta1.field=12

I want to return values even if ta2.field is null!

In SQL Server its (*=):
select ta1.* from table1 ta1, table2 ta2 where ta1.field*=ta2.field and ta1.field=12

How can I do this in MySQL?

Thanks
Telmo Cardoso
 
select
ta1.*
from table1 ta1 left join table2 ta2 using(field)
where ta1.field=12
 
actually, microsoft recommends that you stop using the silly asterisk in your joins

(i'm sorry, i do not mean to suggest that you are silly, merely that the asterisk join syntax is silly, and long overdue to be retired)

SQL Server supports LEFT [OUTER] JOIN syntax too

r937.com | rudy.ca
 
:D lol

actually its not my code... I'm migrating an application from SQL Server to MySQL.... but I'm not a MySQL expert (not even close)...

And I'm looking for a change that gives me less impact on code (or I will have to change line by line instead of replace)...

hvass I'm already using your suggestion... in the meantime this come across:

select cast(field as integer) as num from table

and in MySQL is't working :| but I went thought the documentation and found nothing. Can you guys help me (again)

Sorry :)
Telmo

 
CAST is available as of mysql 4.0.2

you will find it in the documentation under "Cast Functions and Operators"

the syntax you want is

CAST(field AS [UN]SIGNED)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top