mysql合并两个表并排序结果

时间:2018-12-15 13:55:07

标签: mysql

不好意思。我想对表invcount2和reserve1进行合并。下面的代码有什么错误?

@Test
    public void rentBook() {
        Book book = createDummyBook();
        User user = createDummyUser();
        BookRentals bookToRent = createDummyRentedBook(user, book);

        when(userRepository.doesAccountExistsWithGivenID(user.getId())).thenReturn(true);
        when(bookRepository.doesBookExistsWithGivenID(book.getId())).thenReturn(true);
        when(bookRepository.findOne(book.getId())).thenReturn(book);
        when(userRepository.findOne(user.getId())).thenReturn(user);

        String expected = "Book was rented";

        assertEquals(expected, bookRentalService.rentBook(user.getId(), book.getId()));

        verify(bookRentalsRepository, times(1)).save(bookToRent);
    }

1 个答案:

答案 0 :(得分:0)

看来,当您使用order by关键字时,您无法select不能在distinct语句中出现。

您可以检查此SQL link