473,407 Members | 2,676 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,407 software developers and data experts.

WHERE question

Hello all, I am still learning about SQL, and have a question. I have
two tables. I want to update table 2 with data from table 1. Table 1
has two columns. ID and NUM. In Table 2, I have an ID column and a
bunch more columns plus another NUM column. Table 1 was pulled in
from excel. I need to update the NUM from Table 1 to NUM in table 2,
but the formating on the ID fields are different, although the same
numbers. Example: Table 1 ID is ##############, and Table 2 ID is
##___#____##___##___###__####_ where _ = NULL. Also, Table 2 is
formatted as CHAR(30).

Before I screw up the tables, will "WHERE table1.ID = table2.ID" work,
or do I need to do something else to get it to work?

Thanks!

Aug 16 '07 #1
1 1301
ceconix (ce*****@gmail.com) writes:
Hello all, I am still learning about SQL, and have a question. I have
two tables. I want to update table 2 with data from table 1. Table 1
has two columns. ID and NUM. In Table 2, I have an ID column and a
bunch more columns plus another NUM column. Table 1 was pulled in
from excel. I need to update the NUM from Table 1 to NUM in table 2,
but the formating on the ID fields are different, although the same
numbers. Example: Table 1 ID is ##############, and Table 2 ID is
##___#____##___##___###__####_ where _ = NULL. Also, Table 2 is
formatted as CHAR(30).

Before I screw up the tables, will "WHERE table1.ID = table2.ID" work,
or do I need to do something else to get it to work?
I don't really know what you mean with _ = NULL, but I take a stab
that you really mean space. In such case

WHERE table1.ID = replace(table2.ID, ' ', '')

may work.

It always help if you post table definitions and sample data, preferably
as CREATE TABLE statements and INSERT statements.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Aug 16 '07 #2

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

Similar topics

3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
17
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
7
by: MLH | last post by:
Where is system.mdw normally stored in typical A97 installation?
11
by: Geoff Cox | last post by:
Hello, I am trying to get a grip on where to place the initialization of two arrays in the code below which was created using Visual C++ 2005 Express Beta 2... private: static array<String^>^...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
4
by: alf | last post by:
Hi, I can not find out where the extra space comes from. Run following: import os,sys while 1: print 'Question ]?', if sys.stdin.readline().strip() in ('Y','y'): #do something pass
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
43
by: Kislay | last post by:
Which of the following is correct regarding the storage of global variables : 1. Global variables exist in a memory area that exists from before the first reference in a program until after the...
25
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.