Solved

HTML in database query

Posted on 2008-06-20
6
169 Views
Last Modified: 2010-04-21
I am running a simple select statement that outputs records from a clients table returning their ID, First Name and Last Name.

Is there a way to return a link in that table as well, ie, I thought:

select id, alt_id as [Alternate ID], t.first_name as [First Name], t.last_name as [Last Name],
'<a href=https://someurl?id=' & id & '>Link</a>' as Link

would work but it doesn't.
0
Comment
Question by:hyphenpipe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21832174
if the link is stored in a field, you just need to mention that column

select id, alt_id as [Alternate ID], t.first_name as [First Name], t.last_name as [Last Name], Link
from urTable
0
 
LVL 6

Author Comment

by:hyphenpipe
ID: 21832229
The link is not stored in a field.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21832514
You want to return the same link with all the resultset ?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 6

Author Comment

by:hyphenpipe
ID: 21832772
Say I have a table that only contains:

ID, First_Name, Last_Name

I want the output result to be

http://someurl?id=ID where ID is the ID number from the table.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21832881
you used & , but SQL uses +
select id, alt_id as [Alternate ID], t.first_name as [First Name], t.last_name as [Last Name],
'<a href=https://someurl?id=' + CAST(id as varchar(20)) + '>Link</a>' as Link 

Open in new window

0
 
LVL 6

Author Closing Comment

by:hyphenpipe
ID: 31469205
Thanks!!!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question