dstubblefield
asked on
Concat URL & PageID
I need to join/concat the p_URL & pid colums, without loosing the other colums.
Here is the start with all the colums
SELECT pid, p_parent_id, p_primary, p_page_order, p_name, p_desc, p_title, p_content, p_url, p_target, p_meta_words, p_meta_desc, p_show
FROM titzerfuneral.pages
WHERE p_show = MMColParam [is equal to 1]
ORDER BY p_page_order ASC
And here is what I have come up with:
SELECT *, (p_url&'?pid='pid) AS p_url
FROM titzerfuneral.pages
WHERE p_show = MMColParam
ORDER BY p_page_order ASC
Here is the start with all the colums
SELECT pid, p_parent_id, p_primary, p_page_order, p_name, p_desc, p_title, p_content, p_url, p_target, p_meta_words, p_meta_desc, p_show
FROM titzerfuneral.pages
WHERE p_show = MMColParam [is equal to 1]
ORDER BY p_page_order ASC
And here is what I have come up with:
SELECT *, (p_url&'?pid='pid) AS p_url
FROM titzerfuneral.pages
WHERE p_show = MMColParam
ORDER BY p_page_order ASC
ASKER
Database Engine is MsSQL the p_url is default.asp, staff.asp etc. then the pid is the unique key colum together they need to be be like this, default.asp?pid=1 or staff.asp?pid=2, (p_url&'?pid='pid)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get this error "Syntax error converting the varchar value to Default.asp?pid' to a column of data type int"
the 'p_url' is a 'varchar' and the 'pid' is the 'int' key column,
the 'p_url' is a 'varchar' and the 'pid' is the 'int' key column,
ASKER
You just won the points for moving me in the right direction, the answer is:
SELECT myURL = p_url+'?pid='+CAST(pid AS VARCHAR), pid, p_parent_id, p_primary, p_page_order, p_name, p_desc, p_title
FROM titzerfuneral.pages
Just needed to add the CAST(pid AS VARCHAR) to convert the 'int' to a 'varchar'
SELECT myURL = p_url+'?pid='+CAST(pid AS VARCHAR), pid, p_parent_id, p_primary, p_page_order, p_name, p_desc, p_title
FROM titzerfuneral.pages
Just needed to add the CAST(pid AS VARCHAR) to convert the 'int' to a 'varchar'
SELECT joined=p_url+pid,p_parent_
FROM titzerfuneral.pages
WHERE p_show = MMColParam [is equal to 1]
ORDER BY p_page_order ASC
if does not work then what is your database engine?