INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

how to write query to concatonate multiple entries

how to write query to concatonate multiple entries

(OP)
hi,

I have the following sceaio I want to write a query for, but can't think how to do it (assuming it is possible)
(well, i've simplified here to get to the point I want)

Imagin I have a 'rules' and a 'rule instruction' table as follows:

rules
-----
rule_code
rule_description


rule_instructions
-----------------

rule_code
instruction_seqno
instruction_text


what I want to be able to do is write a query that returns a single string comprising of the concatonated 'instruction_text' entries for a give rule

for example:

image the rule instruction table contains:

rule_code instruction_seqno instruction_text
--------- ----------------- -----------------
rule1 1 pick one of these
rule1 2 from each group
rule1 3 but not both
rule2 1 pick as many as you like
rule2 2 upto the maximum cost

what i would like is a seelct statement (or to write a view) that would return :


pick one of these from each group but not both

if i feed it 'rule1'

or
pick as many as you like upto the maximum cost

if I feed it 'rule2'

is this possible?

thanks,

andy

RE: how to write query to concatonate multiple entries

This is really a display layer problem. The front end should be doing the concatenation. Let the database server return the instructions in the proper order, and the front end can easily loop through that recordset, and concatenate as needed.

RE: how to write query to concatonate multiple entries



You could try using the LISTAGG function.
3eyes

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close