[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 4719 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
Conservative discussions
TPS Re-registration case still pending ..
TPS for Nepal likely to extend next week
सालीको चाक
ChatSansar.com Naya Nepal Chat
TPS for Venezuela is terminated, only 60 days extension for transition period
TPS to F1 Status.
TPS To F-1 COS
Venezuela TPS lawuit
Toilet paper or water?
tesla stock OMG !!
Those who are in TPS, what’s your backup plan?
Biden out, Trump next president, so what’s gonna happen to TPS, termination?
Homeland Security revokes temporary status for 532,000 Cubans, Haitians, Nicaraguans and Venezuelans
TPS Sakiyo Tara Case is in Court.
Got my F1 reinstatement approved within 3 months(was out of F1 for almost 2 years)
Has anyone here successfully reinstated to F-1 status after a year-long gap following a drop from F-1?
I hope all the fake Nepali refugee get deported
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
Court Hearing Approval.
Looking for girl
Who is hottest nepali female?
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