[Show all top banners]

stylish
Replies to this thread:

More by stylish
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 SQL Help
[VIEWED 3116 TIMES]
SAVE! for ease of future access.
Posted on 07-25-08 6:45 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Hi Frens,

Create table table1

(

col1 varchar(10)

)

Create table table2

(

col2 int

)

insert into table1 values('1,2,3,4')

insert into table2 values(1)

insert into table2 values(2)

insert into table2 values(3)

insert into table2 values(4)

insert into table2 values(5)

insert into table2 values(6)

insert into table2 values(7)

insert into table2 values(8)

insert into table2 values(9)

 

So table1 has 1,2,3,4

Table2 has 1 - 9 as rows

  I want to write a stament so that i get the result set like this 1- 4 as rows that means those values that is in the table1 but remember folks the datatype here is varchar.

WIll appreciate ur help

 


 
Posted on 07-25-08 7:43 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Which database server is this like SQL server, Oracle, or MySQL....
Do you know what kind of language are you using like C#, PHP, ColdFusion ...

 
Posted on 07-25-08 10:53 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

give us lil more detail on this. What language u using and where are you trying to populating the table from. I mean, are you trying to populate data from another table into your table?

However, I am not sure if the following will work, but if you're on Oracle, this might be hint:

insert into table1(col1) (select  myvarchar( col) from (select '1'  as col from dual
                                                                                union
                                                                                select '2' as col from dual
                                                                                union
                                                                                select '3' as col from dual
                                                                                union
                                                                                select '4' as col from dual))

The last select statement, by default, lists values vertically as 4 different rows like:

1
2
3
4
 which has to be converted to 1,2,3,4 as single row in single column.

In this case, I used myvarchar() aggregate function, which I didn't give you detail. You need to define that function in your database. For the second part, you already got the hint.

If you're on SQL server, there might be easier way to do this. Let me know if this is what you're trying to do. I will give you more detail on that aggregate function.


 
Posted on 07-26-08 1:00 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Guys I am using SQL Server. I was creating a stored procs using T-SQL.

Plz help

 


 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 365 days
Recommended Popular Threads Controvertial Threads
Lets play Antakshari...........
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
शीर्षक जे पनि हुन सक्छ।
What are your first memories of when Nepal Television Began?
[New post] Why Would Krishna Have To Run From The Battlefield
Sajha Poll: नेपालका सबैभन्दा आकर्षक महिला को हुन्?
ChatSansar.com Naya Nepal Chat
is Rato Bangala school cheating?
Why always Miss Nepal winner is Newari??
NRN card pros and cons?
Basnet or Basnyat ??
पुलिसनी संग - आज शनिवार - अन्तिम भाग
निगुरो थाहा छ ??
Nas and The Bokas: Coming to a Night Club near you
TPS Re-registration
श्राद्द
सेक्सी कविता - पार्ट २
What Happened to Dual Citizenship Bill
पाप न साप घोप्टो पारि थाप !!
अमेरिकामा छोरा हराएको सूचना
Nas and The Bokas: Coming to a Night Club near you
राजदरबार हत्या काण्ड बारे....
Mr. Dipak Gyawali-ji Talk is Cheap. US sends $ 200 million to Nepal every year.
Harvard Nepali Students Association Blame Israel for hamas terrorist attacks
TPS Update : Jajarkot earthquake
is Rato Bangala school cheating?
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters