[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL query join

Posted on 2011-05-11
3
Medium Priority
?
182 Views
Last Modified: 2012-05-11
I would like to pull these two tables together to I can list by date what tests were given, and also display the name of the test given.

 Table: CompanyTests Table: Tests
0
Comment
Question by:rrhandle8
  • 2
3 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35740368
if the test ids are always three characters, you can join using charindex

select companytest.*, tests.*
from companytests
inner join tests on charindex(cast(tid as varchar), tests) > 0
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 1000 total points
ID: 35740378
here

select companytest.*, tests.*
from companytests
inner join tests on charindex(cast(tests.tid as varchar), companytest.tests) > 0
0
 
LVL 61

Assisted Solution

by:HainKurt
HainKurt earned 1000 total points
ID: 35740557
to be on safe side:

select companytest.*, tests.*
from companytests
inner join tests on charindex(',' + cast(tests.tid as varchar) + ',', ',' + companytest.tests +',') > 0

this will search ",700," in ",700,701,720,721,"
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

830 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