[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 6841 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
ANA and AJAY KUMAR DEV. RAPISTS CONVENTION
NRN card pros and cons?
TPS To F-1 COS
Nepal TPS has been Extended !!!
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?
US citizen Petitioning my wife who was out of status when she was in H1B. What to do ?
Democrat wants to run election like in India. Chaos and Confusing to voters.
Please ask KRISTI NOEM in her facebook and other social media to renew TPS
Supreme Court allows Trump to end TPS for Venezuelans
Nepal TPS decision
TPS to F1 Status.
legal Query for married nepali girl now have taken US citizenship
ICE kidnapping people off the streets over op eds
ए १ पनि पुगेनछ ?
Trump’s “Big Beautiful Bill” is straight-up xenophobic class warfare. Let’s call it what it is.
2020 : Why No Trump !
Business Ideas in Nepal?
A legit Non-Profit organization "United For TPS Nepal "
Leave messages on US congressman's facebook to support TPS
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