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

  • Home
  • SEARCH
  • 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 7591697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:42:54+00:00 2026-05-30T20:42:54+00:00

I have two tables, one with categories and subcategories. Each category and subcategory has

  • 0

I have two tables, one with categories and subcategories. Each category and subcategory has an id and if it’s a subcategory, it’s got a topid != 0 referring what it’s a subcategory of. The other table “markers” has a field ‘cat’ which correlates with the category field ‘name’ Now I want to select everything from markers with category.id = 4 OR category.topid = 4 so I tried this query:

SELECT * FROM `xymply_markers`
JOIN `xymply_categories`
    ON xymply_markers.cat = xymply_categories.name
WHERE xymply_categories.topid=4
    OR xymply_categories.id=4

Which doesn’t return me anything even tho I do have such elements in my table “markers”. Any assistance would be appreciated!

Table schemas:

`xymply_categories` (
  `id` int(11) NOT NULL auto_increment,
  `topid` int(11) NOT NULL,
  `name` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;

`xymply_markers` (
  `created` date NOT NULL,
  `id` int(11) NOT NULL auto_increment,
  `sdate` date NOT NULL,
  `hdate` date NOT NULL,
  `name` varchar(60) NOT NULL,
  `address` varchar(80) NOT NULL,
  `unit` varchar(6) NOT NULL,
  `lat` decimal(10,7) NOT NULL,
  `lng` decimal(10,7) NOT NULL,
  `type` varchar(30) NOT NULL,
  `userid` int(11) NOT NULL,
  `adtext` text NOT NULL,
  `phone` varchar(20) NOT NULL,
  `email` varchar(30) NOT NULL,
  `url` varchar(30) NOT NULL,
  `cat` varchar(4) NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=151 DEFAULT CHARSET=utf8 AUTO_INCREMENT=151 ;

Sample Data:

xymply_categories:

id  1
topid 0
name 'vehicle'
--------------
id  2
topid 1
name 'bike'
--------------
id  3
topid 1
name 'truck'

xymply_markers:

id 1
sdate 2012-03-01
hdate 2012-04-01
name 'TEST'
address '1234 TEST'
unit''
lat 49.0
lng -123.0
adtext 'TEST'
phone '1234567890'
email 'email@email.com'
url 'www.url.com'
cat 'bike'

--------------

id 1
sdate 2012-03-01
hdate 2012-04-01
name 'TEST'
address '1234 TEST'
unit''
lat 49.5
lng -123.5
adtext 'TEST'
phone '1234567890'
email 'email@email.com'
url 'www.url.com'
cat 'vehicle'
  • 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-30T20:42:55+00:00Added an answer on May 30, 2026 at 8:42 pm

    One problem is that the xymply_markers.cat field is VARCHAR(4) but the xymply_categories.name field is TEXT, and contains values longer than 4 characters. Either you’re not giving us the accurate schema, or you’re confused about which columns join, or you’re never going to see any trucks or vehicles. Columns which join should have the same type almost without exception (I’ve never seen a good reason for an exception).

    You are then asking about id = 4 or topid = 4, but the sample data you show only has id = 1 or topid = 1. Do you actually have data where id = 4 or topid = 4 in the system?

    Between these two lots of confusion, it is hard to know what we’re up against. If you have data that joins and has the relevant topid or id values, then your query should work.


    I have a field called ‘id’ in both tables. How can I control which one I’m accessing with PHP after I read data into the array with $row = @mysql_fetch_assoc($result)?

    The simplest way is to ensure that each result column has a unique name, creating one with an ‘alias’, as in:

    SELECT c.id AS category_id,
           c.topid,
           c.name AS category_name,
           m.id AS marker_id,
           m.name AS marker_name,
           ...
    

    PHP will associate the alias names with the the data in the row.

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

Sidebar

Related Questions

I have two tables : one table it matchs and the other is teams.
I have two tables, one that has 450 rows, the other is a Sort
I have tables with listings, categories and one that maps them to each other.
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables one called fs_note the other called dumy_fs_note I created after
I have two tables connected with one to many relationship. Parent Table is a
I have two tables. One user table and one table in which results are
I have two separate tables used for categories. One is Categories(ID, Title, Description) ,
I have two models: store and category with a joining table called categories.stores .
I have three tables in which two are master tables and other one is

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.