Question: I've been reading other similar "multiple records into one" posts, but either cannot seem to get any to work, or they don't really apply to what I am trying to do.

Here are my 3 tables. vehicle, vehicle\_repair, comments

* `vehicle` columns: vehicle\_name and other vehicle related info,vehicle\_make, vehicle\_model
* `vehicle_repair` columns: vehicle\_name, vehicle\_repair\_type, vehicle\_repair\_num, etc, etc
* `comments` columns: vehicle\_name,vehicle\_repair\_num, comments\_detail

The way the program is written, if I write more than 1 line of comments, it doesn't concatenate them, it makes 1 entry for each line, ie:

`comments` table:

```
vehicle_name                 vehicle_rpr_num             comments_detail
--------------------------------------------------------------------
150                           1         replaced hose
750                           1         replaced belt
750                           2         replaced fuel and also saw that the
750                           2         timing belt needs to be replaced
750                           2         as well

```

I was trying to use something like:

```
select 
    substring((select ' '+comments_detail AS 'data()' 
               from comments 
               for xml path('')), 3, 80) as 'comments_detail' 
from 
    comments

```

I tried to add the join and other tables inside the substring but then the comments\_details become all jacked up, like it then combines 20 comments together instead of 1 at a time.

I'd rather start from scratch and see if I can get it working another way.

My issue comes in when I try to link the 3 tables above.

I do not know how to put in the other fields that I need from the vehicle table, ie vehicle\_make, vehicle\_model

Any ideas? Am I writing my concatenate completely wrong? I am trying to put this into a stored procedure, would a view be better?

Answer: 
**Demo** <http://jsfiddle.net/yS8tw/>

Few things to note:

* Use of `document.ready`
* Use of `Val`

**Also** I like this `appendVal` function: <http://jsfiddle.net/5R7eZ/> - [Is it possible to do ".value +=" in JQuery?](https://stackoverflow.com/questions/1224133/is-it-possible-to-do-value-in-jquery)

Rest should fit the needs `:)`

**code**

```
$(document).ready(function(){
      $("#b1").click(toev);
  });

  function toev() {
      var value = $("#b1").val();
      alert(value);
      $("#output").val(value);
  }

```

**With AppendVal**

```
 $(document).ready(function(){
      $("#b1").click(toev);
  });

  function toev() {
      var value = $("#b1").val();

      $("#output").appendVal(value);
  }

 $.fn.appendVal = function (newPart) {
   return this.each(function(){ this.value += newPart; });
 };

```
You can't append content to an `<input>` element because it cannot have content. Perhaps you meant

```
  $('#output').val(value);

```

to set its value.