Hello NG,

I have two tables, three and four fields inside, in my mysql database,
created with phpmyadmin:

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

t_books
1 bookid (primary key, auto_increment)
2 authorid (Typ:index, reference to t_authors.authorid, 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 from the t_authors tabel are one field with
the value inside "lastname, firstname":

"create view v_authornames as
select authorid, lastname || ', ' || firstname  from t_authors"
The purpose of lastname || ', ' || firstname is to get one field with
comma separated values lastname and firstname  form t_authors.
How can I merge this two fields, lastname and firstname, that I will get
one field and inside this field will be the values lastname, firstname from 
the
t_authors table? I don't know the right syntax for
merging the fields? Syntax: lastname || ', ' || firstname is false.

There is another problem inserting sequently values 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 t_books?
And how to phpmyadmin? The field authorid.t_books should be
referenced to the field authorid.t_authors.
Auto_increment of authorid.t_authors is working fine for me.
Auto_increment of bookid.t_books is also working fine for me.
But how can I implement the reference between authorid.t_authors
and authorid.t_books in phpmyadmin and which value for
authorid.t_books.should I set in the command:
"insert into t_books (authorid, title, subtitle)
values ('1'), 'Effektiv C++ Programmieren',
 '50 Wege zur Verbesserung Ihrer Programme und Entwuerfe');"
?
Field authorid.t_books should have the same
auto_incremented values as the field authorid.t_authors.


Best regards

Andreas




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

Reply via email to