Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.

  • 21/11/2023 BLACK FRIDAY 23 is coming

    BIG SALE, 35% discount for all our extensions. Use BF23 coupon code. Hurry up the discount is valid till 27 November.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Help needed to create another query
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Help needed to create another query
#49379
Help needed to create another query 10 Years, 1 Month ago Karma: 0
I have a table with sample datas, as follows,
organization, first_name, last_name, country, date, published, hide_me
xyz, Steve, Small, Hungary, 2014-04-01, 1, 0
zxy, Rob, Big, England, 2014-04-02, 0, 0
yxz, Bob, Middle, Germany, 2014-04-03, 1, 1

I am using this query:
SELECT `organization`, `first_name`, `last_name`, `country`, date(`created_date`) FROM `jos_jd_donors` WHERE `published`=1

The result is

xyz, Steve, Small, Hungary, 2014-04-01
yxz, Bob, Middle, Germany, 2014-04-03

Help me please to create a query, when the hide_me=1, and the result should look like this one:

xyz, Steve, Small, Hungary, 2014-04-01
Anonimous, " ", " ", Germany, 2014-04-03

The name of organization should be changed to Anonimous, the names whould be empty strings. I tried to use the SELECT CASE but no success.
Best regards,
Pista
Last Edit: 2014/05/07 20:06 By ha5ao.
The administrator has disabled public write access.
 
#49380
Re:Help needed to create another query 10 Years, 1 Month ago Karma: 748
Hello,

Do you want to retrieve records where published = 1 and hide_me = 1?

Regards,
ARI Soft
The administrator has disabled public write access.
 
#49381
Re:Help needed to create another query 10 Years, 1 Month ago Karma: 0
I want to retrive when published=1 and hide_me=1, but if the hide_me=1 then the name of organization has to be changed to "Anonimous" and the first name and last name have to be empty.
The administrator has disabled public write access.
 
#49382
Re:Help needed to create another query 10 Years, 1 Month ago Karma: 748
Try the following SQL query:

Code:


SELECT 
  CASE hide_me WHEN 1 THEN '' ELSE `organization` END AS `organization`,
  CASE hide_me WHEN 1 THEN '' ELSE `first_name` END AS `first_name`,
  CASE hide_me WHEN 1 THEN '' ELSE `last_name` END AS `last_name`,  
  `country`, 
  date(`created_date`) 
FROM 
  `jos_jd_donors` 
WHERE 
  `published`=1



Regards,
ARI Soft
Last Edit: 2014/05/08 06:45 By admin.
The administrator has disabled public write access.
 
#49383
Re:Help needed to create another query 10 Years, 1 Month ago Karma: 0
I got "No data available." message.
The administrator has disabled public write access.
 
#49385
Re:Help needed to create another query 10 Years, 1 Month ago Karma: 0
I think I found the solution

SELECT CASE `hide_me` WHEN 1 THEN 'ANONYMOUS' ELSE `organization` END,
CASE hide_me WHEN 1 THEN '' ELSE `first_name` END,
CASE hide_me WHEN 1 THEN '' ELSE `last_name` END,
`country`,
date(`created_date`) AS date
FROM
`jos_jd_donors`
WHERE
`published`=1
ORDER BY date DESC

It seems working.
The administrator has disabled public write access.
 
Go to topPage: 1