PDA

View Full Version : mysql "view" for editing thread.title & post.pagetext


Rik Brown
01-31-2009, 04:49 AM
I've been trying to create my first mysql "view" in order to edit thread titles while viewing the corresponding pagetext to the first post in the thread. I'm using a mysql frontend, Navicat, to display the view but the underlying "view" syntax appears to be the problem.

Here's the basic syntax for the view:

select `thread`.`title` AS `title`,
`post`.`pagetext` AS `post_pagetext`,
`post`.`username` AS `post_username`,
`post`.`postid` AS `post_postid`,
`post`.`threadid` AS `post_threadid`,
`thread`.`forumid` AS `thread_forumid`,
`thread`.`dateline` AS `thread_dateline`
from (`post` join `thread`)
where (`post`.`threadid` = `thread`.`threadid`)
group by `thread`.`threadid`
having ((`thread`.`forumid` = _utf8'505')
and (`thread`.`dateline` < _utf8'1228090965'))
order by `thread`.`title`

I do get the correct view that I'm trying to get. However, I cannot edit the thread titles as I always get an error message advising that the "target table ..... of the update is not updateable."

Does anyone know how to change the view code above to make the target table "updateable" or perhaps has working code they can cut and paste here?

Thanks. -- Rik

Marco van Herwaarden
01-31-2009, 10:13 AM
Why are you creating a view?

Rik Brown
02-01-2009, 08:44 PM
Why are you creating a view?

Because a view will allow me to "view" the database in ways not available through vb.

For example, I can load 1,000 (or more) rows of information into what looks almost like an Excel spreadsheet and pagedown or pageup through that data quickly to exaimine data that matches criteria that I cannot define within vb.

The view gives me much more control and speed than one can have going through vb as the frontend to the database. Plus, its simply time I expand my knowledge of mysql and learn more above constructing views. :)

Regards. -- Rik

Marco van Herwaarden
02-02-2009, 10:42 AM
There is nothing that that you can do with a view, that you can't do on a regular table(s). But depending on the exact format, a view can not always be used to update data. vBulletin itself does not use any views.