473,414 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

SQL ask 2 tables

I have 2 tables (names A B)
i need (In SQL stetments) to search from table A if rows in table B
with this conditions:
A.col1 containe 4 char.
B.col1 containe 4 or more char

need all the records that A.col1 IN B.col1
Best Regards,
Yuval

Jul 23 '05 #1
7 1261
Here's my guess:

SELECT DISTINCT A.col1
FROM A, B
WHERE LEN(A.col1)=4
AND B.col1 LIKE A.col1+'%'

If that's not it and you need more help then please give us a better
specification as explained here:
http://www.aspfaq.com/etiquette.asp?id=5006

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
thanks but,
someting not working
for example
A.col1 = "1142"
B.col1 ="1084 1096 1142 1196"
not show
please help

Jul 23 '05 #3
SELECT A.col1, B.col1
FROM A, B
WHERE LEN(A.col1)=4
AND B.col1 LIKE '%'+A.col1+'%'

Query efficiency goes right out of the window with this addition though.
Normalisation would be recommended if both A and B are large.

Mr Tea

"m_*****@yahoo.com" <yu******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
thanks but,
someting not working
for example
A.col1 = "1142"
B.col1 ="1084 1096 1142 1196"
not show
please help

Jul 23 '05 #4
SELECT DISTINCT A.col1
FROM A, B
WHERE LEN(A.col1)=4
AND ' '+B.col1+' ' LIKE '% '+A.col1+' %'

Why do you have multiple values in a string in B.col1? Non-atomic
columns are a violation of good design and it looks like these should
exist as separate rows rather than a delimited list.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #5
I got the error:

Syntax error converting the varchar value '%' to a column of data type
int

Jul 23 '05 #6
I see that type of A.col1 is Int

A.col1 = 1142
B.col1 ="1084 1096 1142 1196"

Jul 23 '05 #7
Ok i find it
thanks alot.

Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
1
by: Shelby | last post by:
Problem: My company generates its own data export from a propietary database. These (free) tables can be read in C#.NET using a Visual FoxPro driver (vfpoledb). I can read each of the six tables...
59
by: phil-news-nospam | last post by:
In followups by Brian O'Connor (ironcorona) to other posts, he repeats the idea that using tables in CSS is not something that should be done because IE doesn't support it. Of course I'm not happy...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
4
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor...
25
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.