Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 06-10-2007, 12:18 AM   #1
Justin Koivisto
 
Justin Koivisto's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default select, joins & field values in 2 tables

Firstly, here's the example structure and data:

+---------------+
| log |
+---------------+
| id |
| approval_date |
| approved_by |
| page_title |
+---------------+

Data:
4, '2006-01-01 08:32:17', 'admin3', 'index'
....

+---------------+
| content |
+---------------+
| page_title |
| page_uri |
+---------------+

Data:
'PREFIX_index', 'index.html'
'index', 'index.html'
'ARCH_index', 'index.html'


What I want to do is select log.approval_date, log.approved_by and
content.page_uri for the records... The twist is that I want to join the
tables based on the page_title where they will be *different* values in
each table.

For instance, I want to get the following:

'2006-01-01 08:32:17', 'admin3', 'index.html'

This would require that the following would be the constraint for the JOIN:
CONCAT('PREFIX_', log.page_title) = content.page_title

This is the first thing I tried:
SELECT
content.page_uri
, log.approval_date
, log.approved_by
, REPLACE(content.page_title,'PREFIX_','') as xx
FROM content
INNER JOIN log
ON log.page_title = xx
WHERE
content.page_title LIKE 'PREFIX_%'

*** MySQL said: #1054 - Unknown column 'xx' in 'on clause'

Then I tried this:
SELECT
content.page_uri
, log.approval_date
, log.approved_by
FROM content
INNER JOIN log
ON CONCAT('PREFIX_', log.page_title ) = content.page_title
WHERE
content.page_title LIKE 'PREFIX_%'

.... this returned data, but looks like it's pretty much everything in
the log table coupled with the matching entries from the content table
(from the WHERE clause).

Can anyone get me in the right direction for this?

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 06-10-2007, 12:19 AM   #2
Justin Koivisto
 
Justin Koivisto's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default select, joins & field values in 2 tables

Justin Koivisto wrote:
> Firstly, here's the example structure and data:
>
> +---------------+
> | log |
> +---------------+
> | id |
> | approval_date |
> | approved_by |
> | page_title |
> +---------------+
>
> Data:
> 4, '2006-01-01 08:32:17', 'admin3', 'index'
> ...
>
> +---------------+
> | content |
> +---------------+
> | page_title |
> | page_uri |
> +---------------+
>
> Data:
> 'PREFIX_index', 'index.html'
> 'index', 'index.html'
> 'ARCH_index', 'index.html'
>
>
> What I want to do is select log.approval_date, log.approved_by and
> content.page_uri for the records... The twist is that I want to join the
> tables based on the page_title where they will be *different* values in
> each table.
>
> For instance, I want to get the following:
>
> '2006-01-01 08:32:17', 'admin3', 'index.html'
>
> This would require that the following would be the constraint for the JOIN:
> CONCAT('PREFIX_', log.page_title) = content.page_title
>
> This is the first thing I tried:
> SELECT
> content.page_uri
> , log.approval_date
> , log.approved_by
> , REPLACE(content.page_title,'PREFIX_','') as xx
> FROM content
> INNER JOIN log
> ON log.page_title = xx
> WHERE
> content.page_title LIKE 'PREFIX_%'
>
> *** MySQL said: #1054 - Unknown column 'xx' in 'on clause'
>
> Then I tried this:
> SELECT
> content.page_uri
> , log.approval_date
> , log.approved_by
> FROM content
> INNER JOIN log
> ON CONCAT('PREFIX_', log.page_title ) = content.page_title
> WHERE
> content.page_title LIKE 'PREFIX_%'
>
> ... this returned data, but looks like it's pretty much everything in
> the log table coupled with the matching entries from the content table
> (from the WHERE clause).
>
> Can anyone get me in the right direction for this?
>


By the lack of replies, I will just assume that this is not possible and
abandon the thought.

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ? PRS Database 0 05-31-2007 8:48 PM
Only output values from a table that are NOT NULL? Bill Y. Barool Database 1 05-31-2007 8:43 PM
docs about access tables, operation tables, volume tables BradPitt Database 0 05-31-2007 8:42 PM
SELECT DISTINCT with Joins? Aapo V Database 1 05-31-2007 8:39 PM
cmyk values in a bitmap QuickDraw Steve Graphics in general 3 05-28-2007 7:55 PM


Featured Websites




All times are GMT +1. The time now is 12:04 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98