Retrieve a variable number of subsets with different conditions
I have the following database:
CREATE TABLE IF NOT EXISTS city (
id serial primary key,
name character varying UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS inhabitants (
id serial primary key,
fullname character varying UNIQUE NOT NULL,
home integer REFERENCES city
);
INSERT INTO city (name) VALUES
('michigan'),
('washington'),
('new york'),
('london'),
('los angeles')
ON CONFLICT DO NOTHING;
INSERT INTO inhabitants (fullname, home) VALUES
('flannigan, amy', 1),
('hannigan, leon', 1),
('shennanigan, frank', 1),
('catcher, floyd', 2),
('rice, amy', 2),
('black, joe', 2),
('higgins, simon', 3),
('stewart, rick', 3),
('white, frank', 3),
('henson, ben', 5),
('hedge, tim', 5),
('wilson, bill', 5),
('moriarty, doc', 4),
('fletcher, dolores', 4),
('fletcher, hank', 4),
('williamson, ann', 1),
('stewart, mary', 3)
ON CONFLICT DO NOTHING;
I want to extract a varying number of subsets with a varying number of inhabitants for each subset. Currently I am using a query for each subset, e.g., if I need two subsets I may use these two queries:
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'michigan')
ORDER BY random() LIMIT 2;
and
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'london')
ORDER BY random() LIMIT 1;
The results may look like this:
fullname | home
-----------------+------
hannigan, leon | 1
williamson, ann | 1
(2 rows)
and
fullname | home
-------------------+------
fletcher, dolores | 4
(1 row)
I join those two results in Bash, so they look what I actually want:
fullname | home
-------------------+------
hannigan, leon | 1
williamson, ann | 1
fletcher, dolores | 4
(3 rows)
I would like to minimize the number of database calls.
Is there a way to do this with one query (or function) or at least a better way than what I am doing currently?
sql database postgresql
|
show 3 more comments
I have the following database:
CREATE TABLE IF NOT EXISTS city (
id serial primary key,
name character varying UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS inhabitants (
id serial primary key,
fullname character varying UNIQUE NOT NULL,
home integer REFERENCES city
);
INSERT INTO city (name) VALUES
('michigan'),
('washington'),
('new york'),
('london'),
('los angeles')
ON CONFLICT DO NOTHING;
INSERT INTO inhabitants (fullname, home) VALUES
('flannigan, amy', 1),
('hannigan, leon', 1),
('shennanigan, frank', 1),
('catcher, floyd', 2),
('rice, amy', 2),
('black, joe', 2),
('higgins, simon', 3),
('stewart, rick', 3),
('white, frank', 3),
('henson, ben', 5),
('hedge, tim', 5),
('wilson, bill', 5),
('moriarty, doc', 4),
('fletcher, dolores', 4),
('fletcher, hank', 4),
('williamson, ann', 1),
('stewart, mary', 3)
ON CONFLICT DO NOTHING;
I want to extract a varying number of subsets with a varying number of inhabitants for each subset. Currently I am using a query for each subset, e.g., if I need two subsets I may use these two queries:
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'michigan')
ORDER BY random() LIMIT 2;
and
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'london')
ORDER BY random() LIMIT 1;
The results may look like this:
fullname | home
-----------------+------
hannigan, leon | 1
williamson, ann | 1
(2 rows)
and
fullname | home
-------------------+------
fletcher, dolores | 4
(1 row)
I join those two results in Bash, so they look what I actually want:
fullname | home
-------------------+------
hannigan, leon | 1
williamson, ann | 1
fletcher, dolores | 4
(3 rows)
I would like to minimize the number of database calls.
Is there a way to do this with one query (or function) or at least a better way than what I am doing currently?
sql database postgresql
Not really related to your code, but you realize Michigan and Washington aren't cities, right? Washington, D.C. would be a city, but Michigan is most definitely a state.
– Steve-o169
Dec 27 '18 at 20:05
@Steve-o169 You do realize that this is just a dumb example and not a geography contest, right?
– nautical
Dec 27 '18 at 20:55
Don't have to win any contests to know the difference between a city and a state. Just saying.
– Steve-o169
Dec 27 '18 at 20:58
@Steve-o169 Oh boy, you are one of those. I am not native to the US and really do not care. You do realize that the world does not revolve around the US, right?
– nautical
Dec 27 '18 at 21:04
Never claimed it did, but if you're unfamiliar with the geography of a place, why not use examples you are familiar with? I'm not one to get into dumb internet arguments, was just making an observation and you decided to get triggered.
– Steve-o169
Dec 27 '18 at 21:06
|
show 3 more comments
I have the following database:
CREATE TABLE IF NOT EXISTS city (
id serial primary key,
name character varying UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS inhabitants (
id serial primary key,
fullname character varying UNIQUE NOT NULL,
home integer REFERENCES city
);
INSERT INTO city (name) VALUES
('michigan'),
('washington'),
('new york'),
('london'),
('los angeles')
ON CONFLICT DO NOTHING;
INSERT INTO inhabitants (fullname, home) VALUES
('flannigan, amy', 1),
('hannigan, leon', 1),
('shennanigan, frank', 1),
('catcher, floyd', 2),
('rice, amy', 2),
('black, joe', 2),
('higgins, simon', 3),
('stewart, rick', 3),
('white, frank', 3),
('henson, ben', 5),
('hedge, tim', 5),
('wilson, bill', 5),
('moriarty, doc', 4),
('fletcher, dolores', 4),
('fletcher, hank', 4),
('williamson, ann', 1),
('stewart, mary', 3)
ON CONFLICT DO NOTHING;
I want to extract a varying number of subsets with a varying number of inhabitants for each subset. Currently I am using a query for each subset, e.g., if I need two subsets I may use these two queries:
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'michigan')
ORDER BY random() LIMIT 2;
and
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'london')
ORDER BY random() LIMIT 1;
The results may look like this:
fullname | home
-----------------+------
hannigan, leon | 1
williamson, ann | 1
(2 rows)
and
fullname | home
-------------------+------
fletcher, dolores | 4
(1 row)
I join those two results in Bash, so they look what I actually want:
fullname | home
-------------------+------
hannigan, leon | 1
williamson, ann | 1
fletcher, dolores | 4
(3 rows)
I would like to minimize the number of database calls.
Is there a way to do this with one query (or function) or at least a better way than what I am doing currently?
sql database postgresql
I have the following database:
CREATE TABLE IF NOT EXISTS city (
id serial primary key,
name character varying UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS inhabitants (
id serial primary key,
fullname character varying UNIQUE NOT NULL,
home integer REFERENCES city
);
INSERT INTO city (name) VALUES
('michigan'),
('washington'),
('new york'),
('london'),
('los angeles')
ON CONFLICT DO NOTHING;
INSERT INTO inhabitants (fullname, home) VALUES
('flannigan, amy', 1),
('hannigan, leon', 1),
('shennanigan, frank', 1),
('catcher, floyd', 2),
('rice, amy', 2),
('black, joe', 2),
('higgins, simon', 3),
('stewart, rick', 3),
('white, frank', 3),
('henson, ben', 5),
('hedge, tim', 5),
('wilson, bill', 5),
('moriarty, doc', 4),
('fletcher, dolores', 4),
('fletcher, hank', 4),
('williamson, ann', 1),
('stewart, mary', 3)
ON CONFLICT DO NOTHING;
I want to extract a varying number of subsets with a varying number of inhabitants for each subset. Currently I am using a query for each subset, e.g., if I need two subsets I may use these two queries:
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'michigan')
ORDER BY random() LIMIT 2;
and
select fullname, home from inhabitants i
where home = (SELECT id FROM city WHERE name = 'london')
ORDER BY random() LIMIT 1;
The results may look like this:
fullname | home
-----------------+------
hannigan, leon | 1
williamson, ann | 1
(2 rows)
and
fullname | home
-------------------+------
fletcher, dolores | 4
(1 row)
I join those two results in Bash, so they look what I actually want:
fullname | home
-------------------+------
hannigan, leon | 1
williamson, ann | 1
fletcher, dolores | 4
(3 rows)
I would like to minimize the number of database calls.
Is there a way to do this with one query (or function) or at least a better way than what I am doing currently?
sql database postgresql
sql database postgresql
asked Dec 27 '18 at 19:51
nautical
1,5381134
1,5381134
Not really related to your code, but you realize Michigan and Washington aren't cities, right? Washington, D.C. would be a city, but Michigan is most definitely a state.
– Steve-o169
Dec 27 '18 at 20:05
@Steve-o169 You do realize that this is just a dumb example and not a geography contest, right?
– nautical
Dec 27 '18 at 20:55
Don't have to win any contests to know the difference between a city and a state. Just saying.
– Steve-o169
Dec 27 '18 at 20:58
@Steve-o169 Oh boy, you are one of those. I am not native to the US and really do not care. You do realize that the world does not revolve around the US, right?
– nautical
Dec 27 '18 at 21:04
Never claimed it did, but if you're unfamiliar with the geography of a place, why not use examples you are familiar with? I'm not one to get into dumb internet arguments, was just making an observation and you decided to get triggered.
– Steve-o169
Dec 27 '18 at 21:06
|
show 3 more comments
Not really related to your code, but you realize Michigan and Washington aren't cities, right? Washington, D.C. would be a city, but Michigan is most definitely a state.
– Steve-o169
Dec 27 '18 at 20:05
@Steve-o169 You do realize that this is just a dumb example and not a geography contest, right?
– nautical
Dec 27 '18 at 20:55
Don't have to win any contests to know the difference between a city and a state. Just saying.
– Steve-o169
Dec 27 '18 at 20:58
@Steve-o169 Oh boy, you are one of those. I am not native to the US and really do not care. You do realize that the world does not revolve around the US, right?
– nautical
Dec 27 '18 at 21:04
Never claimed it did, but if you're unfamiliar with the geography of a place, why not use examples you are familiar with? I'm not one to get into dumb internet arguments, was just making an observation and you decided to get triggered.
– Steve-o169
Dec 27 '18 at 21:06
Not really related to your code, but you realize Michigan and Washington aren't cities, right? Washington, D.C. would be a city, but Michigan is most definitely a state.
– Steve-o169
Dec 27 '18 at 20:05
Not really related to your code, but you realize Michigan and Washington aren't cities, right? Washington, D.C. would be a city, but Michigan is most definitely a state.
– Steve-o169
Dec 27 '18 at 20:05
@Steve-o169 You do realize that this is just a dumb example and not a geography contest, right?
– nautical
Dec 27 '18 at 20:55
@Steve-o169 You do realize that this is just a dumb example and not a geography contest, right?
– nautical
Dec 27 '18 at 20:55
Don't have to win any contests to know the difference between a city and a state. Just saying.
– Steve-o169
Dec 27 '18 at 20:58
Don't have to win any contests to know the difference between a city and a state. Just saying.
– Steve-o169
Dec 27 '18 at 20:58
@Steve-o169 Oh boy, you are one of those. I am not native to the US and really do not care. You do realize that the world does not revolve around the US, right?
– nautical
Dec 27 '18 at 21:04
@Steve-o169 Oh boy, you are one of those. I am not native to the US and really do not care. You do realize that the world does not revolve around the US, right?
– nautical
Dec 27 '18 at 21:04
Never claimed it did, but if you're unfamiliar with the geography of a place, why not use examples you are familiar with? I'm not one to get into dumb internet arguments, was just making an observation and you decided to get triggered.
– Steve-o169
Dec 27 '18 at 21:06
Never claimed it did, but if you're unfamiliar with the geography of a place, why not use examples you are familiar with? I'm not one to get into dumb internet arguments, was just making an observation and you decided to get triggered.
– Steve-o169
Dec 27 '18 at 21:06
|
show 3 more comments
1 Answer
1
active
oldest
votes
Use window functions:
select fullname, home
from (select i.*,
row_number() over (partition by home order by random()) as seqnum
from inhabitants i
) i join
city c
on c.id = i.home
where (name = 'michigan' and seqnum <= 2) or
(name = 'london' and seqnum <= 1)
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.orneeded in thewhereclause.
– nautical
Dec 27 '18 at 21:00
@nautical . . . So modify thewhereclause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.
– Gordon Linoff
Dec 27 '18 at 21:33
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function likecreate function testfun(VARIADIC varchar) ... where name = ANY($1);and call it with a varying number of arguments:select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.
– nautical
Dec 28 '18 at 17:39
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53950179%2fretrieve-a-variable-number-of-subsets-with-different-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use window functions:
select fullname, home
from (select i.*,
row_number() over (partition by home order by random()) as seqnum
from inhabitants i
) i join
city c
on c.id = i.home
where (name = 'michigan' and seqnum <= 2) or
(name = 'london' and seqnum <= 1)
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.orneeded in thewhereclause.
– nautical
Dec 27 '18 at 21:00
@nautical . . . So modify thewhereclause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.
– Gordon Linoff
Dec 27 '18 at 21:33
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function likecreate function testfun(VARIADIC varchar) ... where name = ANY($1);and call it with a varying number of arguments:select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.
– nautical
Dec 28 '18 at 17:39
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
add a comment |
Use window functions:
select fullname, home
from (select i.*,
row_number() over (partition by home order by random()) as seqnum
from inhabitants i
) i join
city c
on c.id = i.home
where (name = 'michigan' and seqnum <= 2) or
(name = 'london' and seqnum <= 1)
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.orneeded in thewhereclause.
– nautical
Dec 27 '18 at 21:00
@nautical . . . So modify thewhereclause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.
– Gordon Linoff
Dec 27 '18 at 21:33
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function likecreate function testfun(VARIADIC varchar) ... where name = ANY($1);and call it with a varying number of arguments:select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.
– nautical
Dec 28 '18 at 17:39
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
add a comment |
Use window functions:
select fullname, home
from (select i.*,
row_number() over (partition by home order by random()) as seqnum
from inhabitants i
) i join
city c
on c.id = i.home
where (name = 'michigan' and seqnum <= 2) or
(name = 'london' and seqnum <= 1)
Use window functions:
select fullname, home
from (select i.*,
row_number() over (partition by home order by random()) as seqnum
from inhabitants i
) i join
city c
on c.id = i.home
where (name = 'michigan' and seqnum <= 2) or
(name = 'london' and seqnum <= 1)
answered Dec 27 '18 at 20:04
Gordon Linoff
759k35292399
759k35292399
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.orneeded in thewhereclause.
– nautical
Dec 27 '18 at 21:00
@nautical . . . So modify thewhereclause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.
– Gordon Linoff
Dec 27 '18 at 21:33
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function likecreate function testfun(VARIADIC varchar) ... where name = ANY($1);and call it with a varying number of arguments:select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.
– nautical
Dec 28 '18 at 17:39
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
add a comment |
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.orneeded in thewhereclause.
– nautical
Dec 27 '18 at 21:00
@nautical . . . So modify thewhereclause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.
– Gordon Linoff
Dec 27 '18 at 21:33
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function likecreate function testfun(VARIADIC varchar) ... where name = ANY($1);and call it with a varying number of arguments:select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.
– nautical
Dec 28 '18 at 17:39
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.
or needed in the where clause.– nautical
Dec 27 '18 at 21:00
The problem with this is, that it extracts exactly two subsets. The number of subsets can vary, though, i.e., there may be a third, fourth etc.
or needed in the where clause.– nautical
Dec 27 '18 at 21:00
@nautical . . . So modify the
where clause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.– Gordon Linoff
Dec 27 '18 at 21:33
@nautical . . . So modify the
where clause to get what you need. Your question is about two specific cities, but the query is pretty obviously generalizable.– Gordon Linoff
Dec 27 '18 at 21:33
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function like
create function testfun(VARIADIC varchar) ... where name = ANY($1); and call it with a varying number of arguments: select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.– nautical
Dec 28 '18 at 17:39
Sorry, this may be obious to you, but I only do sql every once in a while. I can put the above query in a function like
create function testfun(VARIADIC varchar) ... where name = ANY($1); and call it with a varying number of arguments: select * from testfun('michigan','london','los angeles');. However, this returns all entries which match the cities. I do not know how to work in the limits. The only way I can think of, currently, is by string concatenation inside a script. Eventually, I just want to call my script with the citiy,limit pairs and have the query execute automatically.– nautical
Dec 28 '18 at 17:39
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
@nautical . . . This question is about constructing a query, and it has been answered. If you have another question about constructing a function with a particular type of arguments, then ask another question.
– Gordon Linoff
Dec 28 '18 at 23:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53950179%2fretrieve-a-variable-number-of-subsets-with-different-conditions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not really related to your code, but you realize Michigan and Washington aren't cities, right? Washington, D.C. would be a city, but Michigan is most definitely a state.
– Steve-o169
Dec 27 '18 at 20:05
@Steve-o169 You do realize that this is just a dumb example and not a geography contest, right?
– nautical
Dec 27 '18 at 20:55
Don't have to win any contests to know the difference between a city and a state. Just saying.
– Steve-o169
Dec 27 '18 at 20:58
@Steve-o169 Oh boy, you are one of those. I am not native to the US and really do not care. You do realize that the world does not revolve around the US, right?
– nautical
Dec 27 '18 at 21:04
Never claimed it did, but if you're unfamiliar with the geography of a place, why not use examples you are familiar with? I'm not one to get into dumb internet arguments, was just making an observation and you decided to get triggered.
– Steve-o169
Dec 27 '18 at 21:06