Just an update >> From a example I see on internet they had 2 tables. One is for US states (in my case Provincies), and the other was for cities with State Letters (in my case Gemeenten with Provincie Letters).
And what I would like to establish is through Joomla have a selectbox with choices Provincies, and eventually make a choice out of Gemeenten inside that Provincie.
I hope this makes sense. Can anyone tell me if this is the correct way?
First table is called ‘provincies’:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for provincies
-- ----------------------------
DROP TABLE IF EXISTS `provincies`;
CREATE TABLE `provincies` (
`provincie` varchar(22) NOT NULL,
`provincie_code` char(2) NOT NULL,
PRIMARY KEY (`provincie_code`)
) ENGINE=MyISAM;
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `provincies` VALUES ('Drente', 'DR');
Second table is called ‘gemeenten’:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for gemeenten
-- ----------------------------
DROP TABLE IF EXISTS `gemeenten`;
CREATE TABLE `gemeenten` (
`gemeente` varchar(50) NOT NULL,
`provincie_code` char(2) NOT NULL,
KEY `idx_provincie_code` (`provincie_code`)
) ENGINE=MyISAM;
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `gemeenten` VALUES ('Aa en Hunze', 'DR');
I do have a problem with that. I tried in table Gemeenten to set Gemeente as Primary key, and it says: duplicate entry “Bergen” for key “PRIMARY”.
I think the reason is that I have names which often have the same name inside: Bergen, Haaksbergen, Bergen op Zoom, etc.
And, I don’t have id’s inside that table, should I have those?
Hi thanks again,
ps. ‘sned’ was ment to be ‘send’. lol
I checked the entries and see inside some Provincie(s) it has a Gemeente with the exact same name… bummer.
How can I accomplish this. Do I need to make it just one table?
Users should enter : Gemeente and I need to display: Gemeente | Provincie
After that they need to be able to click Provincie and display a list of ALL inside Provincie
And they need to be able to click Gemeente and display a list of ALL inside Gemeente
Thanks, really cool.
So in general language it would mean something as:
select provincie and gemeente
from table provincies use provincie
from table gemeenten use gemeente
connect those two by provincie_code
return the provincie and gemeente only if gemeente has the word Bergen inside
I do not know so much of querying a databse, do you have some websites i could go to learn. I really do not want to take all your time…