0

I need to generate the dynamic url by getting the id of table and other fields. but for this url i need only id

my query is working but i need the id value for every record in this [CARD ID] http://mysite.com/webaplication/postcard/view?id=[CARD ID]&shared

SELECT
            `user`.`first_name` 'First Name',
            `user`.`last_name` 'Last Name',
             CASE `card`.`shared` WHEN 1 THEN 'http://mysite.com/webapplication/card/view?id=**`card`.`id`**&shared' ELSE 'No URL' END 'URL',   
            `card`.`created` 'Created', 
            CASE `card`.`shared` WHEN 1 THEN 'Yes' ELSE 'No' END 'Shared'

        FROM
            `user`, `card`
        WHERE `card`.`id` =`user`.`id`
        GROUP BY
            `card`.`id`

Thanks in advance!!

1 Answer 1

1

Use CONCAT function.

(...)
CASE `card`.`shared` WHEN 1 THEN CONCAT('http://mysite.com/webapplication/card/view?id=', `card`.`id`, '&shared') ELSE 'No URL' END 'URL',   

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat

Sign up to request clarification or add additional context in comments.

1 Comment

quick qn. can you pls tell me how to get all the time(for every record) url not just when it is 1..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.