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 8814883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:14:22+00:00 2026-06-14T04:14:22+00:00

I am hoping someone will be able to point me in the right direction.

  • 0

I am hoping someone will be able to point me in the right direction.

I have a COUNTRY table, containing a primary ID, and country name (e.g. France)

I have a second table PAYMETHODS_COUNTRIES, which contains a primary id, payment method id (e.g. 4) and country id

I am trying to output a list of checkboxes on each payment method, to control which countries (or users in which countries) have access to those local payment methods.

I have the checkbox list working okay, and the processing of the form is also working. The last remaining thing, is to output the list of country checkboxes with selected countries (e.g. this payment method is available in France and Germany) shown as CHECKED.

So what I am trying to do is to output a complete list of all countries

SELECT id, name FROM country ORDER BY id ASC

And then include the PAYMETHODS_COUNTRIES table something like this (not working of course)

SELECT country.id AS countryid,
country.name AS countryname,
paymethods_countries.id AS methodid
FROM country LEFT JOIN `paymethods_countries` 
ON country.id = paymethods_countries.country
WHERE paymethods_countries.paymethod = 10

This example query only shows rows that actually have a record in PAYMETHODS_COUNTRIES, not what I am after.

What I was hoping for, is a complete list of country.id + country.name, with a final field (the ID of the PAYMETHODS_COUNTRIES table) – which should be null where there is no link. That way I should be able to check for null or otherwise, and output CHECKED for those rows.

Hopefully that makes sense – or if anyone knows a better way to achieve what I am doing, your thoughts are appreciated.

  • 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-06-14T04:14:24+00:00Added an answer on June 14, 2026 at 4:14 am

    While the other answer here will produce the desired result, semantically it is more correct to move the condition from the WHERE clause to the ON clause:

    SELECT country.id AS countryid,
        country.name AS countryname,
        paymethods_countries.id AS methodid
    FROM country 
    LEFT JOIN `paymethods_countries` 
       ON country.id = paymethods_countries.country and paymethods_countries.paymethod = 10
    

    This eliminates the need to add the extra OR condition in the WHERE clause.

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

Sidebar

Related Questions

I'm hoping someone will be able to point me in the right direction. I'm
I hoping someone may be able to point me in the right direction for
I was hoping someone could point me in the right direction here. I have
Hoping someone can point me in the right direction. I'm building a online shop
I have a semi-complicated problem and hoping that someone here will be able to
I have a very unusual situation that I am hoping someone will be able
I'm hoping someone have encountered this problem before and will be able to help
Im hoping someone will be able to help. I have created my first stored
Pretty new to PowerShell and hoping someone can point me in the right direction.
I am hoping someone can point me in a right direction. I am writing

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.