Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:13+00:00 2026-05-28T07:59:13+00:00

* revised, but still not solved…* I want to combine data from two files

  • 0

* revised, but still not solved…*

I want to combine data from two files but I am having trouble expressing the sort. I want to sort on either the CREATED date from the first file and the SHARED_DATE from the second file if it exists and it is larger.

file 1 : NODE 
fields: CREATED, CHANGED

file 2 : SHARE_CONTENT   
fields:  SHARED_DATE ,  NODE (foreign key)

…

SELECT n.created, s.shared_date,

(CASE WHEN s.shared_date <> NULL
   then  s.shared_date
   else n.created
END) 
as lastshare

FROM node as n LEFT JOIN share_content as s on (s.nid=n.nid)

ORDER BY lastshare DESC

another possibility..

SELECT n.created, s.shared_date,
FROM node as n LEFT JOIN share_content as s on (s.nid=n.nid)
ORDER BY MAX(n.created, s.shared_date) DESC

except mySQL does not seem to like MAX(a,b)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:59:14+00:00Added an answer on May 28, 2026 at 7:59 am
    SELECT n.created, s.shared_date,
    (CASE WHEN (s.shared_date IS NOT NULL) And (s.Shared_Date > n.Created)
       then  s.shared_date
       else n.created
    END) 
    as lastshare
    FROM node as n LEFT JOIN share_content as s on (s.nid=n.nid)
    ORDER BY lastshare DESC
    

    Specifically note the IS NOT instead of <>. NULL is very, very special in SQL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
EDIT: To answer some questions, this is the revised and still not working code
I have revised a jquery box : http://designer-depot.com/manset/test.html In <ol></ol> everything work perfect. But
I know it isn't possible to inherit from a generic type parameter, but it
(Didn't mean to create a new question, but revised the old one enough that
Revised: I have a list items on the page that I'm creating from database
I'm trying to get matches of single bracket followed by a non-space, but not
I'm trying to bind the SelectedItem to a View. But the view is not
I'm sure I'm contravening some deep dark law of javascript, but I'm not really
After learning that JADE does not support Mobile Agent concept but supports only traditional

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.