Asked by:
POSTGRESQL adding particular column data from one table to another based on unique id

Question
-
I have 2 tables in which we have common values as names field and i need to fetch id from one table to another table based on names. there is lot of data that i can't manually give hard core values. i tried this
update name set name_id = example.id from example where lower(example.id) = lower(name.id)
with this code i am able to fetch only 6000 records out of 12000. what might be the issue
Divija Vemulapalli
- Moved by Dan GuzmanMVP Monday, February 12, 2018 12:28 PM Move off-topic post
Monday, February 12, 2018 12:14 PM
All replies
-
See: https://www.postgresql.org/community/Monday, February 12, 2018 12:27 PM
-
This is a Microsoft SQL Server forum for topics related to data access using SQL Native Client, OLEDB, ODBC, ADO, etc.
From PostgreSQL questions, I suggest you ask on Stackoverflow (https://stackoverflow.com) with a PostgreSQL tag.
Dan Guzman, Data Platform MVP, http://www.dbdelta.com
Monday, February 12, 2018 12:27 PM -
I have 2 tables in which we have common values as names field and i need to fetch id from one table to another table based on names. there is lot of data that i can't manually give hard core values. i tried this
update name set name_id = example.id from example where lower(example.id) = lower(name.id)
with this code i am able to fetch only 6000 records out of 12000. what might be the issue
Divija Vemulapalli
first of all this is not a forum for POSTGRESQL
This is MS SQL Server forum and solution given here are guaranteed to work in SQLServer only
Anyways in t-sql your query can be better written as
update n set name_id = e.id from example e join name n on lower(e.id) = lower(n.id)
if it still doesn't work, it may be that you've some unprintable characters in column like space, hard space etc
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
----------------------------
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook PageMonday, February 12, 2018 12:30 PM -
I actually tried this as well and not able to fetch the data & yes i have some spaces at the beginning.
Divija Vemulapalli
Tuesday, February 13, 2018 6:54 AM -
Thanks for showing me the right community & sorry for the trouble.
Divija Vemulapalli
Tuesday, February 13, 2018 6:54 AM