Author Topic: Create views on fields?  (Read 218 times)

0 Members and 1 Guest are viewing this topic.

Offline t.boTopic starter

  • Enthusiast
    • View Profile
Create views on fields?
« on: February 07, 2010, 03:35:25 PM »
Hey all,

Currently I have 3 different websites that are administrated for 90% on their own. The other 10% are the user tables. I wanted to make sure the user can register 1 time for 3 websites and have one profile for the 3 websites. So I created views for 2 websites user tables. These are now linked to the tables of the first website. This way al that I wanted works...except for one thing.
In the user table there is one field called avatar. This field is responsible for the picture each user has. I want it to be possible to have all fields shared over the 3 websites except this field. This way the user can have different avatars for each website.
So basically my question is:
Can I create views for just one field? OR
Can I create a view for a table and exclude 1 field from that table to function on it's own?

Kind regards,

Thibaut

Offline Mchl

  • Guru
  • Freak!
  • *
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • BOINC@Poland
Re: Create views on fields?
« Reply #1 on: February 07, 2010, 04:57:44 PM »
Yes and yes, and you can also move avatar information to another table altogether and link it to user profile in 1 to many relationship.
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Code: [Select]
brugere i panik

Offline t.boTopic starter

  • Enthusiast
    • View Profile
Re: Create views on fields?
« Reply #2 on: February 08, 2010, 05:33:30 AM »
That's great news. Thank you for your reply Mchl.
Now, at the moment I did a CREATE VIEW for the whole table. If I delete and recreate the one 'avatar' field in the 'slave' table, will this work? I mean is this the correct way to exclude one field from the view?

Kind regards,

thibaut
« Last Edit: February 08, 2010, 05:34:34 AM by t.bo »

Offline Mchl

  • Guru
  • Freak!
  • *
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • BOINC@Poland
Re: Create views on fields?
« Reply #3 on: February 08, 2010, 05:47:11 AM »
I don't exactly understand what you mean. You can create a view from most simple (i.e. without subqueries) SELECT statements.
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Code: [Select]
brugere i panik

Offline t.boTopic starter

  • Enthusiast
    • View Profile
Re: Create views on fields?
« Reply #4 on: February 08, 2010, 05:55:11 AM »
Well I already created a view for the whole table like this
Code: [Select]
CREATE VIEW lvn_users AS SELECT * FROM dbk_users
In the lvn_users table there is a field called 'avatar'. So my question is how do I exclude this field from the current view? Do I just drop the field and recreate it or do I need to drop the whole table 'lvn_users' and do something else?

greets

Offline Mchl

  • Guru
  • Freak!
  • *
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • BOINC@Poland
Re: Create views on fields?
« Reply #5 on: February 08, 2010, 06:08:57 AM »
Code: [Select]
CREATE VIEW lvn_users AS SELECT allFieldsExceptAvatar FROM dbk_users
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Code: [Select]
brugere i panik

Offline t.boTopic starter

  • Enthusiast
    • View Profile
Re: Create views on fields?
« Reply #6 on: February 08, 2010, 09:52:35 AM »
Ok I have tried this. However now ofc there is no avatar field anymore in the slave table.  I also cannot create a normal extra field 'Avatar'. That means the user cannot have an avatar in the slave site.
So I guess if you create a view for one or more fields, that counts for the whole table... :-(


Thanks tho for the help!

Offline Mchl

  • Guru
  • Freak!
  • *
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • BOINC@Poland
Re: Create views on fields?
« Reply #7 on: February 08, 2010, 10:19:35 AM »
You need to create a view based on JOIN of your user table and a table with avatars for 'slave' site.
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Code: [Select]
brugere i panik

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.