Solved

Issue with MySQL VIEW column size

Posted on 2009-04-13
6
395 Views
Last Modified: 2013-12-12
Hi,

I have Product table with columns prod_id int(11),category_id int(11),prod_name varchar(255) and prod_quantity varchar(255).
I am creating VIEW in MySQL using above table  and following syntax:

CREATE OR REPLACE VIEW product_view AS
SELECT
 category_id,
 CONCAT("#",GROUP_CONCAT(CONCAT_WS('=',prod_name,prod_quantity) SEPARATOR '#'),"#") AS product_quantity_values

FROM
 product
GROUP BY category_id

Now when i describe VIEW then the column size of VIEW COLUMN "product_quantity_values" shows varchar(343). So this view only allow me to store 343 characters in COLUMN "product_quantity_values" . More than that are truncated.

Is there any way to avoid such behavior? I want the VIEW COLUMN "product_quantity_values" should store more characters.

0
Comment
Question by:teenashah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24128586
please try this:
CREATE OR REPLACE VIEW product_view AS
SELECT
 category_id,
 cast(CONCAT("#",GROUP_CONCAT(CONCAT_WS('=',prod_name,prod_quantity) SEPARATOR '#'),"#") AS product_quantity_values as VARCHAR(65000)) 
FROM 
 product 
GROUP BY category_id

Open in new window

0
 

Author Comment

by:teenashah
ID: 24128719
Hi angelIII,

Its giving a error:

Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS fproduct_quantity_values as VARCHAR(65000))

BTW: I am using MySQL 5
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24128828
sorry,...
CREATE OR REPLACE VIEW product_view AS
SELECT
 category_id,
 cast(CONCAT("#",GROUP_CONCAT(CONCAT_WS('=',prod_name,prod_quantity) SEPARATOR '#'),"#") as VARCHAR(65000))  AS product_quantity_values 
FROM  product 
GROUP BY category_id

Open in new window

0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:teenashah
ID: 24129011
Sorry angelIII,

Same error again.

Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR(65000)) AS
0
 

Author Comment

by:teenashah
ID: 24135661
Hi,

Above issue has been resolved.

MySQL 5 CAST function allows type as CHAR Not VARCHAR.

But thanks for giving way to tackle situation.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24136813
I see, glad I could help.
so, please, close the question.
a3
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This article discusses how to implement server side field validation and display customized error messages to the client.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question