create view v_authornames as
       select authorid, CONCAT(lastname,',',firstname)
       from t_authors;

Or replace the middle term in the CONCAT function to whatever you want
to separate it -- ie, ' ' for a space, or just
CONCAT(lastname,firstname) to get output "KritzerSheeri".

-Sheeri

On 6/25/06, Andreas Bauer <[EMAIL PROTECTED]> wrote:
Hello NG,

I have two tables in my mysql database
created with phpmyadmin:

t_authors:
1 authorid (primary key, auto_increment)
2 lastname
3 firstname

And a table named t_books, fields inside:

t_books:
1 bookid (primary key, auto_increment)
2 authorid (Typ:index, reference to authorid from t_authors done
  with phpmyadmin)
3 title
4 subtitle

Now I want to create a view from t_authors, so that the fields
of lastname and firstname are one field with
the value inside: "lastname, firstname":

create view v_authornames as
       select authorid, lastname || ', ' || firstname
       from t_authors;

But this view created only an empty field named
lastname ||', ' firstname. How can I join this two
fields so that I get one and this value?

There is another problem of me inserting values sequently in
the two tables:


insert into t_authors (lastname, firstname)
values ('Meyers', 'Scott');

insert into t_books (authorid, title, subtitle)
values ('1'), 'Effektiv C++ Programmieren',
       '50 Wege zur Verbesserung Ihrer Programme und Entwuerfe');

insert into t_books (authorid, title, subtitle)
values ('1'), 'Mehr Effektiv C++ Programmieren',
       '35 neue Wege zur Verbesserung Ihrer Entwuerfe und Programme');

insert into t_authors (lastname, firstname)
values ('Schlossnagle', 'George');

insert into t_books (authorid, title, subtitle)
values ('1'), 'Advanced PHP Programming', 'A practical guide');


The problem is the authorid of t_books: which value should I take for
authorid of table t_books.
If I took '1', the referenced value of the authorid from t_authors was not
taken from the authorid from t_books, but always the value '1'?
If I took '0' or others I get errors.
In phpmyamin I set the reference to t_authors.authorid in the
t_books.authorid field.

Best regards and many thanks

Andreas



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to