[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 3764 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 90 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
Toilet paper or water?
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
Tourist Visa - Seeking Suggestions and Guidance
From Trump “I will revoke TPS, and deport them back to their country.”
I hope all the fake Nepali refugee get deported
Those who are in TPS, what’s your backup plan?
advanced parole
Sajha Poll: Who is your favorite Nepali actress?
ढ्याउ गर्दा दसैँको खसी गनाउच
To Sajha admin
Problems of Nepalese students in US
Mamta kafle bhatt is still missing
अरुणिमाले दोस्रो पोई भेट्टाइछिन्
Are Nepalese cheapstakes?
Nepali Psycho
MAGA denaturalization proposal!!
How to Retrieve a Copy of Domestic Violence Complaint???
wanna be ruled by stupid or an Idiot ?
All the Qatar ailines from Nepal canceled to USA
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