If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > CREATE VIEW with ENUM columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-25-10, 13:48
vivoices vivoices is offline
Registered User
 
Join Date: Jul 2009
Posts: 45
Arrow CREATE VIEW with ENUM columns

Is it possible to create a view with ENUM type columns?

I would get the ENUM values from foreign key tables.


Thanks,
David
Reply With Quote
  #2 (permalink)  
Old 12-25-10, 14:03
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by vivoices View Post
Is it possible to create a view with ENUM type columns?
of course

CREATE VIEW foo AS
SELECT * FROM daTable WHERE userid=937

Quote:
Originally Posted by vivoices View Post
I would get the ENUM values from foreign key tables.
could you explain what you mean by this?

what's a "foreign key table" and what does "get" mean?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-25-10, 14:22
vivoices vivoices is offline
Registered User
 
Join Date: Jul 2009
Posts: 45
My main purpose is to insert and update new rows to a "html_text_field_texts" table more conveniently in phpMyAdmin.

I have a "html_text_field_texts" table with "htmlTextId, pageTypeId, pageId, localeId, htmlTextFieldId, htmlText" columns.

My first attempt was to create a "HTML Texts" view with the following SELECT statement:

Code:
SELECT
		html_text_field_texts.htmlTextId
	,	page_types.pageTypeName
	,	pages.pageName
	,	locales.locale
	,	html_text_field_names.htmlTextFieldName
	,	html_text_field_texts.htmlText

FROM
	html_text_field_texts
	INNER JOIN
		page_types
	ON
		page_types.pageTypeId = html_text_field_texts.pageTypeId

	INNER JOIN
		pages
	ON
		pages.pageId = html_text_field_texts.pageId

	INNER JOIN
		locales
	ON
		locales.localeId = html_text_field_texts.localeId

	INNER JOIN
		html_text_field_names
	ON
		html_text_field_names.htmlTextFieldId = html_text_field_texts.htmlTextFieldId

WHERE
	locales.enabled = '1'
Now when I go to the INSERT form for the "HTML Texts" view in phpMyAdmin, the column types are the same as the selected columns from the original tables, e.g. "pageTypeName" is varchar(30) etc.
I want the VIEW to have ENUM type columns and set the ENUM values for e. g. the"pageTypeName" column of the VIEW from the UNIQUE values of "page_types.pageTypeName".

Thanks,
David
Reply With Quote
  #4 (permalink)  
Old 12-25-10, 15:41
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by vivoices View Post
I want the VIEW to have ENUM type columns and set the ENUM values for e. g. the"pageTypeName" column of the VIEW from the UNIQUE values of "page_types.pageTypeName".
you lost me right about there

i'm sorry, i don't understand what you want

i would expect the values of page_types.pageTypeName to be strings, like VARCHAR(99) or something, not ENUMs
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 12-25-10, 16:56
vivoices vivoices is offline
Registered User
 
Join Date: Jul 2009
Posts: 45
Quote:
Originally Posted by r937 View Post
i would expect the values of page_types.pageTypeName to be strings, like VARCHAR(99) or something, not ENUMs
yes, "page_types.pageTypeName" is varchar(30).
So the INSERT dialog of phpMyAdmin displays it as such, so I have to manually type in a pagetype name, but I want to choose one of the existing values of "page_types.pageTypeName".
phpMyAdmin would create a dialog, that does exactly that when the column type of the VIEW could be set to ENUM and populated with all values from "page_types.pageTypeName".
Reply With Quote
  #6 (permalink)  
Old 12-25-10, 17:48
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
i am afraid i still don't understand what you're doing

maybe because i don't use phpmyadmin

but the idea of inserting into a view also makes me a bit queasy

good luck to you

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 12-26-10, 02:26
vivoices vivoices is offline
Registered User
 
Join Date: Jul 2009
Posts: 45
What kind of problems could arise while inserting into a view?

phpMyAdmin is not very flexible as a CRUD.
Maybe HeidiSQL could do what I need i.e. showing the values of a "value" column in a dropdown of a "new/update row dialog" and then enter "valueIndex" (primary key of table "values") into the "valueIndex" column of table "combinationOfValues".
Unfortunately phpMyAdmin is the only access I have to that specific database.

I will have to build my own simple CRUD with php/js. I tried DaDaBIK and did not like it.

Thank you for your time,
David
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On