Ask a Question related to Coldfusion Database Access, Design and Development.
-
rmorgan #1
Query w/bad table structure
Hi,
I am trying to query a column that has multiple values. When I export it, I
need to have it so that each of those values is placed in its own column
instead of them being grouped together. What might the mysql syntax be to
accomplish this? TIA.
rmorgan Guest
-
Copy a table in Access structure only with CF query
Hello, I need to know how to create a new table by copying an existing table with the table structure only in a query Don't know the Syntax but... -
Accessing a Query in a structure
I am creating a session variable that is a structure. Each key in the structure stores a query that I created via QueryNew. I can output the query... -
Query to Structure?
Hi. I wanted to ask if someone knew how to do the following: I have a structure and a query. <cfset myStruct = StructNew()> <cfset... -
Creating new table with same structure as existing one
I need to create "archive" table that will have the same structure as "production" one. When I run my program it have to create table named... -
query to return table structure
hi, Is there any command or query that returns the table structure informix. -
Sojovi #2
Re: Query w/bad table structure
Are you trying to convert a column into a row ?
Regards
Sojovi Guest
-
Kronin555 #3
Re: Query w/bad table structure
There's no way to do this directly in a database query. You have 2 choices:
redesign your database to fix this
-or-
do the conversion in Coldfusion (do the query, loop through the query creating
a new query and separating out the values)
If you are storing multiple values in a single field in your database, either
comma-delimited, space-delimited, or some other way, then you aren't working
with a normalized database structure and aren't using the database how it was
designed (which is why you can't do this directly in a query).
Kronin555 Guest
-
rmorgan #4
Re: Query w/bad table structure
I guess you could say that Sojovi
The origianal column, lets call it OrigCol has these possible values
101,102,103,104
To start with I need to run the query to create a tab delimited file and the
end result needs to look like:
"101" "102" "103" "104"
instead of : "101 102 103 104" like it does right now.
rmorgan Guest
-
Dan Bracuk #5
Re: Query w/bad table structure
Originally posted by: rmorgan
I guess you could say that Sojovi
The origianal column, lets call it OrigCol has these possible values
101,102,103,104
To start with I need to run the query to create a tab delimited file and the
end result needs to look like:
"101" "102" "103" "104"
instead of : "101 102 103 104" like it does right now.
See if the listqualify function allows you to use double quotes. I always use
single, so I don't actually know.
Dan Bracuk Guest
-
MikerRoo #6
Re: Query w/bad table structure
Originally posted by: Kronin555
There's no way to do this directly in a database query....
No, you can do this in PostgreSQL and MS SQL. Might be able to do it in
MySQL 5 not sure about that one.
So the answer is switch to PostgreSQL!
MikerRoo Guest
-
Kronin555 #7
Re: Query w/bad table structure
MikerRoo, I'd be interested to see how you can do this in PostgreSQL. Could you
post an example? I'm assuming you're proposing using a column type of ARRAY or
a composite type... even with that I don't know how you can get what the
original poster was asking for.
Kronin555 Guest
-
MikerRoo #8
Re: Query w/bad table structure
The basic technique is to use a UDF that parses the string into a record set.
I don't have an example here at work (a MS SQL shop). I'll fire up the ole
abacus at home when I get a chance, if you still need an example.
MikerRoo Guest
-
Kronin555 #9
Re: Query w/bad table structure
> The basic technique is to use a UDF that parses the string into a record set.
Ah, gotcha. Yes, this could be handled with a UDF or stored procedure. I never
considered that angle, but would be a good fix if changing the database schema
is out of the question. I haven't written many UDFs or stored procs, so don't
consider it as often as I probably should when looking for a solution to a
problem.
Kronin555 Guest
-
MikerRoo #10
Re: Query w/bad table structure
Anyway, (as you correctly point out) if you have to do this then some DB
designer has not done an adequate job.
The correct thing to do is to fix the DB design and "calibrate" the original
designer if he's within range.
MikerRoo Guest



Reply With Quote

