Forums
This topic is locked
Join two fields query
02 Feb 2005 20:50:38 Chriz L. posted:
I have this table with 3 columns | Id | Num1 | Num2| with values. I want to create a query where to get this table |Id|Num| where num will be num1 if num2=0 else will be num2.
Any suggestions?
Thank you in advance.
Replies
Replied 03 Feb 2005 00:04:57
03 Feb 2005 00:04:57 Chris Charlton replied:
What database server you using? (MySQL, Access, SQL Server, ...)
Replied 03 Feb 2005 07:48:03
03 Feb 2005 07:48:03 Chriz L. replied:
MS Access...
Replied 06 Feb 2005 16:42:44
06 Feb 2005 16:42:44 Vince Baker replied:
You may have to handle this on the page rather than in the SQL statement itself, for example:
Create a recordset that pulls both Num1 and Num2
In your table where you want this number to be shown:
<% if yourrecordsetname("Num2" = "0" then %>
<%=yourrecordsetname("Num1"%>
<% else %>
<%=yourrecordsetname("Num2" %>
<% end if %>
This way it will show the value you want on the page but the condition is handled outside of the sql statement.
Regards
Vince
DMX Manager
Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)
VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting
Create a recordset that pulls both Num1 and Num2
In your table where you want this number to be shown:
<% if yourrecordsetname("Num2" = "0" then %>
<%=yourrecordsetname("Num1"%>
<% else %>
<%=yourrecordsetname("Num2" %>
<% end if %>
This way it will show the value you want on the page but the condition is handled outside of the sql statement.
Regards
Vince
DMX Manager
Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)
VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting