diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index d824b8b974408ecb17d807464aaf783be86ee4b8..6738ba54f4660d980a4443c04206167f01cb79f9 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -4817,14 +4817,13 @@ selectExpander(Walker * pWalker, Select * p)
 				int space_id =
 					box_space_id_by_name(t_name,
 							     strlen(t_name));
-				if (space_id == BOX_ID_NIL) {
+				struct space *space = space_by_id(space_id);
+				if (space == NULL) {
 					sqlite3ErrorMsg(pParse,
 							"no such table: %s",
 							t_name);
 					return WRC_Abort;
 				}
-				struct space *space = space_by_id(space_id);
-
 				if (space->def->field_count <= 0) {
 					sqlite3ErrorMsg(pParse, "no format for"\
 							" space: %s", t_name);
diff --git a/test/sql/checks.result b/test/sql/checks.result
index 2a31b01022579fecebbcebf0b0637f6048f7a5d0..3084d89c365a11625b4d939679a1c525d59aeffb 100644
--- a/test/sql/checks.result
+++ b/test/sql/checks.result
@@ -105,6 +105,17 @@ s = box.space._space:insert(t)
 ---
 - error: 'Wrong space options (field 5): invalid MsgPack map field ''name'' type'
 ...
+--
+-- gh-3611: Segfault on table creation with check referencing this table
+--
+box.sql.execute("CREATE TABLE w2 (s1 INT PRIMARY KEY, CHECK ((SELECT COUNT(*) FROM w2) = 0));")
+---
+- error: 'Failed to create space ''W2'': SQL error: no such table: W2'
+...
+box.sql.execute("DROP TABLE w2;")
+---
+- error: 'no such table: W2'
+...
 test_run:cmd("clear filter")
 ---
 - true
diff --git a/test/sql/checks.test.lua b/test/sql/checks.test.lua
index 7ff78fe48faeb7a2ab2e7a0e98e2d15bbe5c253a..fb958092e03d4e7c4ea325ad32456e63a0bd5c04 100644
--- a/test/sql/checks.test.lua
+++ b/test/sql/checks.test.lua
@@ -43,4 +43,11 @@ format = {{name = 'X', type = 'unsigned'}}
 t = {513, 1, 'test', 'memtx', 0, opts, format}
 s = box.space._space:insert(t)
 
+
+--
+-- gh-3611: Segfault on table creation with check referencing this table
+--
+box.sql.execute("CREATE TABLE w2 (s1 INT PRIMARY KEY, CHECK ((SELECT COUNT(*) FROM w2) = 0));")
+box.sql.execute("DROP TABLE w2;")
+
 test_run:cmd("clear filter")